# coding: utf-8
import os, sys, copy, time, datetime
import pickle

import numpy as np
import pandas as pd
from tqdm import tqdm
import openpyxl
import uuid

import warnings

from utils.load_access_data import *
from utils.file_process import get_col_str_type
from utils.logging_config import setup_logger

warnings.filterwarnings('ignore')
logger = setup_logger('Data Mapping')

class Config:
    target_cols = ['channelno', 'dataid', 'iesign', 'datatype', 'writeoffflag'
            , 'writeoffdataid', 'outputdate', 'origincountrycode', 'origincountry', 'countrycodeofdelivery'
            , 'countryofdelivery', 'importername', 'importeraddress', 'importercontact', 'suppliername'
            , 'supplieraddress', 'suppliercontact', 'hscode', 'hscodedescription', 'commoditydescription'
            , 'totalcifvalue', 'totalfobvalue', 'grossweight', 'netweight', 'quantity'
            , 'quantityunit', 'teu', 'importer_forwarderagent', 'supplier_forwarderagent', 'abnormaldata'
            , 'portofloading', 'portofdestination', 'loadingcountrycode', 'loadingcountry', 'transportterm'
            , 'tradeterm', 'paymentterm', 'carrier', 'containerno', 'vesselname'
            , 'brand', 'version', 'country', 'IMPORTER_ID', 'SUPPLIER_ID', 'cif_currency', 'fob_currency']
config = Config

# 1
def ARG_get_target_import(imp_path, src_cols):
    """
    阿根廷 进口
    1	拉丁美洲	ARGENTINA	阿根廷	ARG
    """
    start=time.time()
    src_col_type = get_col_str_type(src_cols)
    imp_df = pd.read_csv(imp_path
                         , header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {imp_df.columns.values}')
    
    target_tab = pd.DataFrame(columns=config.target_cols)
    
    target_tab['channelno']          = ['zdzj'] * imp_df.shape[0]          # 渠道缩写
    target_tab['dataid']             = imp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = imp_df['iesign']                    # 进出口标志
    target_tab['datatype']           = ['D'] * imp_df.shape[0]             # 提单关单标志
    target_tab['writeoffflag']       = ['o'] * imp_df.shape[0]             # 冲销标志
    target_tab['outputdate'] = [f'{int(x[0]):04d}-{int(x[1]):02d}-{int(x[2]):02d}' for x in imp_df.loc[:,['YEAR', 'MONTH', 'DAY']].values]             # 日期
    # 需要转写为标准英文国名
    target_tab['origincountrycode'] = imp_df['ORIGIN_COUNTRY']            # 原产国国际编码
    target_tab['origincountry'] = imp_df['ORIGIN_COUNTRY']            # 原产国英文名称
    target_tab['countrycodeofdelivery'] = ['ARG'] * imp_df.shape[0]            # 目的国国际编码
    target_tab['countryofdelivery'] = ['ARGENTINA'] * imp_df.shape[0]              # 目的国英文名称（需转写为标准英文国名）
    
    target_tab['importername'] = imp_df['IMPORTER']                   # 采购商名称
    # target_tab['importeraddress']    = imp_df['aaaaa']                     # 采购商地址
    # target_tab['importercontact']    = imp_df['aaaaa']                     # 采购商联系方式
    # target_tab['suppliername']       = imp_df['aaaaa']                     # 供应商名称
    # target_tab['supplieraddress']    = imp_df['aaaaa']                     # 供应商地址
    # target_tab['suppliercontact']    = imp_df['aaaaa']                     # 供应商联系方式
    target_tab['hscode'] = imp_df['HS_CODE']                    # hs编码
    # target_tab['hscodedescription']  = imp_df['aaaaa']                     # hs编码描述
    target_tab['commoditydescription'] = [str(x).replace("\"", " ") if x is not None else x for x in imp_df['PRODUCT_DESC'].values]                                               # 产品描述
    target_tab['totalcifvalue'] = [extract_float_before_second_dot(x) for x in imp_df['ITEM_CIF'].values]                # cif总价
    target_tab['totalfobvalue'] = [extract_float_before_second_dot(x) for x in imp_df['SUBITEM_FOB'].values]                      # fob总价
    target_tab['grossweight'] = imp_df['G_WEIGHT']
    # target_tab['netweight']          = imp_df['aaaaa']                     # 重量
    target_tab['quantity']           = imp_df['QUANTITY']                  # 数量
    target_tab['quantityunit'] = imp_df['UNIT_OF_QUANTITY']          # 数量单位
    # target_tab['teu']                = imp_df['aaaaa']                      # TEU
    # 需要判断根据imp_df['IMPORTER']判断是否为0/1
    # target_tab['importer_forwarderagent'] = [0]*imp_df.shape[0]          # 采购商货代公司标签（需根据IMPORTER判断0/1）
    # target_tab['supplier_forwarderagent'] = imp_df['aaaaa']                # 供应商货代公司标签
    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签

    # 待判定
    target_tab['abnormaldata'] = [0]*imp_df.shape[0]               # 是否命中异常数据规则（待判定）
    
    target_tab['portofloading'] = imp_df['ORIGIN_PORT']                      # 启运港
    target_tab['portofdestination'] = imp_df['CUSTOMS']                      # 目的港
    # 国家需转换为标准英文国名
    target_tab['loadingcountrycode'] = imp_df['ORIGIN_COUNTRY']             # 启运国国际编码（需转换为标准英文国名）
    target_tab['loadingcountry'] = imp_df['ORIGIN_COUNTRY']             # 启运国英文名称（需转换为标准英文国名）
    
    # 需映射成统一枚举值
    target_tab['transportterm']        = imp_df['TRANS_TYPE']                 # 运输方式（需映射成统一枚举值）
    
    # 需映射成统一枚举值
    target_tab['tradeterm'] = imp_df['INCOTERMS']                              # 成交方式（需映射成统一枚举值）
    # target_tab['paymentterm']        = imp_df['aaaaa']                      # 付款方式
    # target_tab['carrier']            = imp_df['aaaaa']                      # 承运人名称
    # target_tab['containerno']        = imp_df['aaaaa']                      # 集装箱箱号
    # target_tab['vesselname']         = imp_df['aaaaa']                      # 船名
    target_tab['brand']                = imp_df['BRAND']                      # 品牌
    target_tab['version']            = imp_df['version']                      # 版本
    target_tab['country']            = imp_df['src_country']                      # 国家
    target_tab['IMPORTER_ID']          = imp_df['IMPORT_ID']                  # 渠道采购商编码
    # target_tab['SUPPLIER_ID']        = imp_df['aaaaa']                      # 渠道供应商编码
    target_tab['cif_currency'] = 'ARG'                         # cif货币类型
    target_tab['fob_currency'] = 'ARG'                         # fob货币类型
    
    end=time.time()
    logger.info(f'Import data mapping and cleaning takes {round((end-start)/60,2)} minutes')
    
    return target_tab.loc[:,config.target_cols]

def ARG_get_target_export(exp_path, src_cols):
    """
    阿根廷 出口
    1	拉丁美洲	ARGENTINA	阿根廷	ARG
    """
    start=time.time()
    
    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    exp_df = pd.read_csv(exp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {exp_df.columns.values}')
    
    target_tab = pd.DataFrame(columns=config.target_cols)
    
    target_tab['channelno']          = ['zdzj'] * exp_df.shape[0]          # 渠道缩写
    target_tab['dataid']             = exp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = exp_df['iesign']                    # 进出口标志
    target_tab['datatype']           = ['D'] * exp_df.shape[0]             # 提单关单标志
    target_tab['writeoffflag']       = ['o'] * exp_df.shape[0]             # 冲销标志
    # target_tab['writeoffdataid']     = exp_df['aaaaa']                   # 冲销记录主键
    target_tab['outputdate'] = [f'{int(x[0]):04d}-{int(x[1]):02d}-{int(x[2]):02d}' for x in exp_df.loc[:,['YEAR', 'MONTH', 'DAY']].values]
    # 原产来源国需要再确认
    target_tab['origincountrycode'] = ['ARG']*exp_df.shape[0]               # 原产国国际编码
    target_tab['origincountry'] = ['ARGENTINA']*exp_df.shape[0]             # 原产国英文名称
    # 需要转写为标准英文国名
    target_tab['countrycodeofdelivery'] = exp_df['DEST_COUNTRY']            # 目的国国际编码
    target_tab['countryofdelivery'] = exp_df['DEST_COUNTRY']                # 目的国英文名称（需转写为标准英文国名）

    # target_tab['importername']       = exp_df['aaaaa']                     # 采购商名称
    # target_tab['importeraddress']    = exp_df['aaaaa']                     # 采购商地址
    # target_tab['importercontact']    = exp_df['aaaaa']                     # 采购商联系方式
    target_tab['suppliername'] = exp_df['EXPORTER']                          # 供应商名称
    # target_tab['supplieraddress']    = exp_df['aaaaa']                     # 供应商地址
    # target_tab['suppliercontact']    = exp_df['aaaaa']                     # 供应商联系方式
    target_tab['hscode'] = exp_df['HS_CODE']                                 # hs编码
    # target_tab['hscodedescription']  = exp_df['aaaaa']                     # hs编码描述
    target_tab['commoditydescription'] = [str(x).replace("\"", " ") if x is not None else x for x in exp_df['PRODUCT_DESC'].values]                                               # 产品描述
    target_tab['totalcifvalue'] = [extract_float_before_second_dot(x) for x in exp_df['ITEM_CIF'].values]                         # cif总价
    target_tab['totalfobvalue'] = [extract_float_before_second_dot(x) for x in exp_df['SUBITEM_FOB'].values]                         # fob总价
    target_tab['grossweight'] = exp_df['G_WEIGHT']                           # 毛重
    # target_tab['netweight']          = exp_df['aaaaa']                     # 重量
    target_tab['quantity'] = exp_df['QUANTITY']                  # 数量
    target_tab['quantityunit'] = exp_df['UNIT_OF_QUANTITY']          # 数量单位
    # target_tab['teu']                = exp_df['aaaaa']                      # TEU
    # target_tab['importer_forwarderagent'] = exp_df['aaaaa']                # 采购商货代公司标签
    # 需要判断根据imp_df['EXPORTER']判断是否为0/1
    # target_tab['supplier_forwarderagent'] = [0]*exp_df.shape[0]          # 供应商货代公司标签（需根据EXPORTER判断0/1）
    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签

    
    # 待判定
    target_tab['abnormaldata']       = [0] * exp_df.shape[0]               # 是否命中异常数据规则（待判定）
    target_tab['portofloading']      = exp_df['CUSTOMS']                  # 启运港
    # target_tab['portofdestination']  = exp_df['aaaaa']                      # 目的港
    
    # 国家需转换为标准英文国名
    target_tab['loadingcountrycode'] = ['ARG']*exp_df.shape[0]             # 启运国国际编码（需转换为标准英文国名）
    target_tab['loadingcountry'] = ['ARGENTINA']*exp_df.shape[0]             # 启运国英文名称（需转换为标准英文国名）
    
    # 需映射成统一枚举值
    target_tab['transportterm'] = exp_df['TRANS_TYPE']                 # 运输方式（需映射成统一枚举值）
    
    # 需映射成统一枚举值
    target_tab['tradeterm'] = exp_df['INCOTERMS']                      # 成交方式（需映射成统一枚举值）
    # target_tab['paymentterm']        = exp_df['aaaaa']                      # 付款方式
    # target_tab['carrier']            = exp_df['aaaaa']                      # 承运人名称
    # target_tab['containerno']        = exp_df['aaaaa']                      # 集装箱箱号
    # target_tab['vesselname']         = exp_df['aaaaa']                      # 船名
    target_tab['brand'] = exp_df['BRAND']                      # 品牌
    target_tab['version']            = exp_df['version']                      # 版本
    target_tab['country']            = exp_df['src_country']                      # 国家
    # target_tab['IMPORTER_ID']        = exp_df['aaaaa']                      # 渠道采购商编码
    target_tab['SUPPLIER_ID'] = exp_df['EXPORT_ID']                  # 渠道供应商编码
    target_tab['cif_currency'] = 'ARG'                         # cif货币类型
    target_tab['fob_currency'] = 'ARG'                         # fob货币类型
    
    end=time.time()
    logger.info(f'Export data mapping and cleaning takes {round((end-start)/60,2)} minutes')
    
    return target_tab.loc[:,config.target_cols]


# 2
def ETH_get_target_import(imp_path, src_cols):
    """
    埃塞俄比亚 进口
    2	非洲	ETHIOPIA	埃塞俄比亚	ETH
    """
    start=time.time()
    src_col_type = get_col_str_type(src_cols)
    imp_df = pd.read_csv(imp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {imp_df.columns.values}')
    
    target_tab = pd.DataFrame(columns=config.target_cols)
    
    target_tab['channelno'] = ['zdzj']*imp_df.shape[0] # 渠道缩写
    target_tab['dataid']             = imp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = imp_df['iesign']                    # 进出口标志
    target_tab['datatype'] = ['D'] * imp_df.shape[0] # 提单关单标志
    target_tab['writeoffflag'] = ['o']*imp_df.shape[0] # 冲销标志
    # target_tab['writeoffdataid'] = imp_df['aaa'] # 冲销记录主键
    
    target_tab['outputdate'] = [f'{int(x[0]):04d}-{int(x[1]):02d}-{int(x[2]):02d}' for x in imp_df.loc[:,['YEAR', 'MONTH', 'DAY']].values] # 日期
    target_tab['origincountrycode'] = imp_df['ORIGIN_COUNTRY'] # 原产国国际编码
    target_tab['origincountry'] = imp_df['ORIGIN_COUNTRY'] # 原产国英文名称
    target_tab['countrycodeofdelivery'] = ['ETH'] * imp_df.shape[0] # 目的国国际编码
    target_tab['countryofdelivery'] = ['ETHIOPIA'] * imp_df.shape[0] # 目的国英文名称
    target_tab['importername'] = imp_df['IMPORTER'] # 采购商名称
    target_tab['importeraddress'] = imp_df['IMPORTER'] # 采购商地址
    target_tab['importercontact'] = imp_df['IMPORTER'] # 采购商联系方式
    # target_tab['suppliername'] = imp_df['aaaaa'] # 供应商名称
    # target_tab['supplieraddress'] = imp_df['aaaaa'] # 供应商地址
    # target_tab['suppliercontact'] = imp_df['aaaaa'] # 供应商联系方式
    target_tab['hscode'] = imp_df['HS_CODE'] # hs编码
    target_tab['hscodedescription'] = imp_df['HS_CODE_DESC'] # hs编码描述
    # target_tab['commoditydescription'] = imp_df['PRODUCT_DESC'] # 产品描述
    target_tab['totalcifvalue'] = imp_df['CIF_IN_USD'] # cif总价
    # target_tab['totalfobvalue'] = imp_df['aaaaa'] # fob总价
    target_tab['grossweight'] = imp_df['G_WEIGHT_IN_KG'] # 毛重
    target_tab['netweight'] = imp_df['N_WEIGHT_IN_KG'] # 重量
    target_tab['quantity'] = imp_df['QUANTITY'] # 数量
    target_tab['quantityunit'] = imp_df['UNIT_OF_QUANTITY'] # 数量单位
    # target_tab['teu'] = imp_df['aaaaa'] # TEU
    # target_tab['importer_forwarderagent'] = imp_df['IMPORTER'] # 采购商货代公司标签
    # target_tab['supplier_forwarderagent'] = imp_df['aaaaa'] # 供应商货代公司标签
    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签

    # target_tab['abnormaldata'] = imp_df['aaaaa'] # 是否命中异常数据规则
    # target_tab['portofloading'] = imp_df['aaaaa'] # 启运港
    # target_tab['portofdestination'] = imp_df['aaaaa'] # 目的港
    # target_tab['loadingcountrycode'] = imp_df['aaaaa'] # 启运国国际编码
    # target_tab['loadingcountry'] = imp_df['aaaaa'] # 启运国英文名称
    # target_tab['transportterm'] = imp_df['aaaaa'] # 运输方式
    # target_tab['tradeterm'] = imp_df['aaaaa'] # 成交方式
    # target_tab['paymentterm'] = imp_df['aaaaa'] # 付款方式
    # target_tab['carrier'] = imp_df['aaaaa'] # 承运人名称
    # target_tab['containerno'] = imp_df['aaaaa'] # 集装箱箱号
    # target_tab['vesselname'] = imp_df['aaaaa'] # 船名
    # target_tab['brand'] = imp_df['aaaaa'] # 品牌
    target_tab['version'] = imp_df['version'] # 版本
    target_tab['country'] = imp_df['src_country'] # 国家
    # target_tab['IMPORTER_ID'] = imp_df['aaaaa'] # 渠道采购商编码
    # target_tab['SUPPLIER_ID'] = imp_df['aaaaa'] # 渠道供应商编码
    target_tab['cif_currency'] = 'USD'                         # cif货币类型
    target_tab['fob_currency'] = 'USD'                         # fob货币类型
    
    end=time.time()
    logger.info(f'Import data mapping and cleaning takes {round((end-start)/60,2)} minutes')
    
    return target_tab.loc[:,config.target_cols]

def ETH_get_target_export(exp_path, src_cols):
    """
    埃塞俄比亚 出口
    2	非洲	ETHIOPIA	埃塞俄比亚	ETH
    """
    start=time.time()
    
    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    exp_df = pd.read_csv(exp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {exp_df.columns.values}')
    
    target_tab = pd.DataFrame(columns=config.target_cols)
    
    target_tab['channelno'] = ['zdzj']*exp_df.shape[0] # 渠道缩写
    target_tab['dataid']             = exp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = exp_df['iesign']                    # 进出口标志
    target_tab['datatype'] = ['D'] * exp_df.shape[0] # 提单关单标志
    target_tab['writeoffflag'] = ['o']*exp_df.shape[0] # 冲销标志
    # target_tab['writeoffdataid'] = exp_df['aaa'] # 冲销记录主键
    
    target_tab['outputdate'] = pd.to_datetime(exp_df['REG_DATE'], format='mixed').dt.strftime('%Y-%m-%d').values  # 日期
    target_tab['origincountrycode']   = ['ETH'] * exp_df.shape[0]          # 原产国国际编码
    target_tab['origincountry']       = ['ETHIOPIA'] * exp_df.shape[0]     # 原产国英文名称
    target_tab['countrycodeofdelivery'] = exp_df['DEST_COUNTRY'] # 目的国国际编码
    target_tab['countryofdelivery'] = exp_df['DEST_COUNTRY'] # 目的国英文名称
    # target_tab['importername'] = exp_df['aaaaa'] # 采购商名称
    # target_tab['importeraddress'] = exp_df['aaaaa'] # 采购商地址
    # target_tab['importercontact'] = exp_df['aaaaa'] # 采购商联系方式
    target_tab['suppliername'] = exp_df['EXPORTER'] # 供应商名称
    target_tab['supplieraddress'] = exp_df['EXPORTER'] # 供应商地址
    target_tab['suppliercontact'] = exp_df['EXPORTER'] # 供应商联系方式
    target_tab['hscode'] = exp_df['HS_CODE'] # hs编码
    target_tab['hscodedescription'] = exp_df['HS_CODE_DESC'] # hs编码描述
    target_tab['commoditydescription'] = exp_df['PRODUCT_DESC'] # 产品描述
    # target_tab['totalcifvalue'] = exp_df['aaaaa'] # cif总价
    target_tab['totalfobvalue'] = exp_df['FOB_VALUE_IN_USD'] # fob总价
    target_tab['grossweight'] = exp_df['G_WEIGHT_IN_KG'] # 毛重
    target_tab['netweight'] = exp_df['N_WEIGHT_IN_KG'] # 重量
    target_tab['quantity'] = exp_df['QUANTITY'] # 数量
    target_tab['quantityunit'] = exp_df['UNIT_OF_QUANTITY'] # 数量单位
    # target_tab['teu'] = exp_df['aaaaa'] # TEU
    # target_tab['importer_forwarderagent'] = exp_df['aaaaa'] # 采购商货代公司标签
    # target_tab['supplier_forwarderagent'] = exp_df['EXPORTER'] # 供应商货代公司标签
    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签

    # target_tab['abnormaldata'] = exp_df['aaaaa'] # 是否命中异常数据规则
    # target_tab['portofloading'] = exp_df['aaaaa'] # 启运港
    # target_tab['portofdestination'] = exp_df['aaaaa'] # 目的港
    # target_tab['loadingcountrycode'] = exp_df['aaaaa'] # 启运国国际编码
    # target_tab['loadingcountry'] = exp_df['aaaaa'] # 启运国英文名称
    # target_tab['transportterm'] = exp_df['aaaaa'] # 运输方式
    # target_tab['tradeterm'] = exp_df['aaaaa'] # 成交方式
    # target_tab['paymentterm'] = exp_df['aaaaa'] # 付款方式
    # target_tab['carrier'] = exp_df['aaaaa'] # 承运人名称
    # target_tab['containerno'] = exp_df['aaaaa'] # 集装箱箱号
    # target_tab['vesselname'] = exp_df['aaaaa'] # 船名
    # target_tab['brand'] = exp_df['aaaaa'] # 品牌
    target_tab['version'] = exp_df['version'] # 版本
    target_tab['country'] = exp_df['src_country'] # 国家
    # target_tab['IMPORTER_ID'] = exp_df['aaaaa'] # 渠道采购商编码
    # target_tab['SUPPLIER_ID'] = exp_df['aaaaa'] # 渠道供应商编码
    target_tab['cif_currency'] = 'USD'                         # cif货币类型
    target_tab['fob_currency'] = 'USD'                         # fob货币类型
    
    end=time.time()
    logger.info(f'Export data mapping and cleaning takes {round((end-start)/60,2)} minutes')
    
    return target_tab.loc[:,config.target_cols]


# 3
def PAK_get_target_import(imp_path, src_cols):
    """
    巴基斯坦 进口
    3	亚洲	PAKISTAN	巴基斯坦	PAK
    """
    start=time.time()
    src_col_type = get_col_str_type(src_cols)
    imp_df = pd.read_csv(imp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {imp_df.columns.values}')
    
    target_tab = pd.DataFrame(columns=config.target_cols)
    
    target_tab['channelno'] = ['zdzj'] * imp_df.shape[0]  # 渠道缩写
    target_tab['dataid']             = imp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = imp_df['iesign']                    # 进出口标志
    target_tab['datatype'] = ['D'] * imp_df.shape[0]  # 提单关单标志
    target_tab['writeoffflag'] = ['o'] * imp_df.shape[0]  # 冲销标志
    # target_tab['writeoffdataid'] = imp_df['writeoffdataid']  # 冲销记录主键
    # target_tab['outputdate'] = imp_df['REG_DATE']  # 日期
    target_tab['outputdate'] = pd.to_datetime(imp_df['REG_DATE'], format='mixed').dt.strftime('%Y-%m-%d').values  # 日期
    target_tab['origincountrycode'] = imp_df['ORIGIN_COUNTRY']  # 原产国国际编码
    target_tab['origincountry'] = imp_df['ORIGIN_COUNTRY']  # 原产国英文名称
    target_tab['countrycodeofdelivery'] = ['PAK'] * imp_df.shape[0]  # 目的国国际编码
    target_tab['countryofdelivery'] = ['PAKISTAN'] * imp_df.shape[0]  # 目的国英文名称
    target_tab['importername'] = imp_df['IMPORTER_NAME']  # 采购商名称
    target_tab['importeraddress'] = imp_df['IMPORTER_ADDRESS']  # 采购商地址
    # target_tab['importercontact'] = imp_df['importercontact']  # 采购商联系方式
    target_tab['suppliername'] = imp_df['EXPORTER_NAME']  # 供应商名称
    # target_tab['supplieraddress'] = imp_df['supplieraddress']  # 供应商地址
    # target_tab['suppliercontact'] = imp_df['suppliercontact']  # 供应商联系方式
    target_tab['hscode'] = imp_df['HS_CODE']  # hs编码
    # target_tab['hscodedescription'] = imp_df['hscodedescription']  # hs编码描述
    target_tab['commoditydescription'] = [str(x).replace("\"", " ") if x is not None else x for x in imp_df['PRODUCT_DESC'].values]  # 产品描述
    target_tab['totalcifvalue'] = imp_df['TOTAL_VALUE_USD_ASSIGNED']  # cif总价
    # target_tab['totalfobvalue'] = imp_df['totalfobvalue']  # fob总价
    # target_tab['grossweight'] = imp_df['grossweight']  # 毛重
    # target_tab['netweight'] = imp_df['netweight']  # 重量
    target_tab['quantity'] = imp_df['QUANTITY']  # 数量
    target_tab['quantityunit'] = imp_df['UNIT_OF_QUANTITY']  # 数量单位
    # target_tab['teu'] = imp_df['teu']  # TEU
    # target_tab['importer_forwarderagent'] = [0] * imp_df.shape[0]  # 采购商货代公司标签
    # target_tab['supplier_forwarderagent'] = imp_df['supplier_forwarderagent']  #  供应商货代公司标签
    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签

    target_tab['abnormaldata'] = [0] * imp_df.shape[0]  # 是否命中异常数据规则
    # target_tab['portofloading'] = imp_df['portofloading']  # 启运港
    # target_tab['portofdestination'] = imp_df['portofdestination']  # 目的港
    # target_tab['loadingcountrycode'] = imp_df['loadingcountrycode']  # 启运国国际编码
    # target_tab['loadingcountry'] = imp_df['loadingcountry']  # 启运国英文名称
    # target_tab['transportterm'] = imp_df['transportterm']  # 运输方式
    # target_tab['tradeterm'] = imp_df['tradeterm']  # 成交方式
    # target_tab['paymentterm'] = imp_df['paymentterm']  # 付款方式
    # target_tab['carrier'] = imp_df['carrier']  # 承运人名称
    # target_tab['containerno'] = imp_df['containerno']  # 集装箱箱号
    # target_tab['vesselname'] = imp_df['vesselname']  # 船名
    # target_tab['brand'] = imp_df['brand']  # 品牌
    target_tab['version'] = imp_df['version']  # 版本
    target_tab['country'] = imp_df['src_country']  # 国家
    # target_tab['IMPORTER_ID'] = imp_df['IMPORTER_ID']  # 渠道采购商编码
    # target_tab['SUPPLIER_ID'] = imp_df['SUPPLIER_ID']  # 渠道供应商编码
    target_tab['cif_currency'] = 'USD'                         # cif货币类型
    # target_tab['fob_currency'] = 'USD'                         # fob货币类型
    
    end=time.time()
    logger.info(f'Import data mapping and cleaning takes {round((end-start)/60,2)} minutes')
    return target_tab.loc[:,config.target_cols]

def PAK_get_target_export(exp_path, src_cols):
    """
    巴基斯坦 出口
    3	亚洲	PAKISTAN	巴基斯坦	PAK
    """
    start=time.time()
    
    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    exp_df = pd.read_csv(exp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {exp_df.columns.values}')
    
    target_tab = pd.DataFrame(columns=config.target_cols)
    
    target_tab['channelno'] = ['zdzj'] * exp_df.shape[0]  # 渠道缩写
    target_tab['dataid']             = exp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = exp_df['iesign']                    # 进出口标志
    target_tab['datatype'] = ['D'] * exp_df.shape[0]  # 提单关单标志
    target_tab['writeoffflag'] = ['o'] * exp_df.shape[0]  # 冲销标志
    # target_tab['writeoffdataid'] = exp_df['writeoffdataid']  # 冲销记录主键
    target_tab['outputdate'] = pd.to_datetime(exp_df['REG_DATE'], format='mixed').dt.strftime('%Y-%m-%d').values  # 日期
    target_tab['origincountrycode']   = ['PAK'] * exp_df.shape[0]          # 原产国国际编码
    target_tab['origincountry']       = ['PAKISTAN'] * exp_df.shape[0]     # 原产国英文名称
    target_tab['countrycodeofdelivery'] = exp_df['DEST_COUNTRY']  # 目的国国际编码
    target_tab['countryofdelivery'] = exp_df['DEST_COUNTRY']  # 目的国英文名称
    target_tab['importername'] = exp_df[' IMPORTER_NAME']  # 采购商名称
    # target_tab['importeraddress'] = exp_df['importeraddress']  # 采购商地址
    # target_tab['importercontact'] = exp_df['importercontact']  # 采购商联系方式
    target_tab['suppliername'] = exp_df['EXPORTER_NAME']  # 供应商名称
    # target_tab['supplieraddress'] = exp_df['supplieraddress']  # 供应商地址
    # target_tab['suppliercontact'] = exp_df['suppliercontact']  # 供应商联系方式
    target_tab['hscode'] = exp_df['HS_CODE']  # hs编码
    # target_tab['hscodedescription'] = exp_df['hscodedescription']  # hs编码描述
    target_tab['commoditydescription'] = [str(x).replace("\"", " ") if x is not None else x for x in     exp_df['PRODUCT_DESC'].values]  # 产品描述
    # target_tab['totalcifvalue'] = exp_df['totalcifvalue']  # cif总价
    target_tab['totalfobvalue'] = exp_df['TOTAL_VALUE_PKR']  # fob总价
    # target_tab['grossweight'] = exp_df['grossweight']  # 毛重
    # target_tab['netweight'] = exp_df['netweight']  # 重量
    target_tab['quantity'] = exp_df['QUANTITY']  # 数量
    target_tab['quantityunit'] = exp_df['UNIT_OF_QUANTITY']  # 数量单位
    # target_tab['teu'] = exp_df['teu']  # TEU
    # target_tab['importer_forwarderagent'] = exp_df['importer_forwarderagent']  #  采购商货代公司标签
    # target_tab['supplier_forwarderagent'] = [0] * exp_df.shape[0]  # 供应商货代公司标签
    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签

    target_tab['abnormaldata'] = [0] * exp_df.shape[0]  # 是否命中异常数据规则
    # target_tab['portofloading'] = exp_df['portofloading']  # 启运港
    # target_tab['portofdestination'] = exp_df['portofdestination']  # 目的港
    # target_tab['loadingcountrycode'] = exp_df['loadingcountrycode']  # 启运国国际编码
    # target_tab['loadingcountry'] = exp_df['loadingcountry']  # 启运国英文名称
    # target_tab['transportterm'] = exp_df['transportterm']  # 运输方式
    # target_tab['tradeterm'] = exp_df['tradeterm']  # 成交方式
    # target_tab['paymentterm'] = exp_df['paymentterm']  # 付款方式
    # target_tab['carrier'] = exp_df['carrier']  # 承运人名称
    # target_tab['containerno'] = exp_df['containerno']  # 集装箱箱号
    # target_tab['vesselname'] = exp_df['vesselname']  # 船名
    # target_tab['brand'] = exp_df['brand']  # 品牌
    target_tab['version'] = exp_df['version']  # 版本
    target_tab['country'] = exp_df['src_country']  # 国家
    # target_tab['IMPORTER_ID'] = exp_df['IMPORTER_ID']  # 渠道采购商编码
    # target_tab['SUPPLIER_ID'] = exp_df['SUPPLIER_ID']  # 渠道供应商编码
    # target_tab['cif_currency'] = 'USD'                         # cif货币类型
    target_tab['fob_currency'] = 'PKR'                         # fob货币类型
    
    end=time.time()
    logger.info(f'Export data mapping and cleaning takes {round((end-start)/60,2)} minutes')
    
    return target_tab.loc[:,config.target_cols]


# 4
def PRY_get_target_import(imp_path, src_cols):
    """
    巴拉圭 进口
    4	拉丁美洲	PARAGUAY	巴拉圭	PRY
    """
    start = time.time()
    src_col_type = get_col_str_type(src_cols)
    imp_df = pd.read_csv(imp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {imp_df.columns.values}')
    
    target_tab = pd.DataFrame(columns=config.target_cols)
    
    target_tab['channelno'] = ['zdzj'] * imp_df.shape[0] # 渠道缩写
    # 为每条记录生成独立的UUID并去除横线
    target_tab['dataid']             = imp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = imp_df['iesign']                    # 进出口标志
    target_tab['datatype'] = ['D'] * imp_df.shape[0] # 提单关单标志
    target_tab['writeoffflag'] = ['o'] * imp_df.shape[0] # 冲销标志
    # target_tab['writeoffdataid'] = imp_df['aaaaa'] # 冲销记录主键（暂未获取到对应字段）
    # target_tab['outputdate'] = imp_df['REG_DATE'] # 日期
    target_tab['outputdate'] = pd.to_datetime(imp_df['REG_DATE'], format='mixed').dt.strftime('%Y-%m-%d').values  # 日期
    
    # 需要转写为标准英文国名
    target_tab['origincountrycode'] = imp_df['ORIGIN_COUNTRY'] # 原产国国际编码
    target_tab['origincountry'] = imp_df['ORIGIN_COUNTRY'] # 原产国英文名称
    target_tab['countrycodeofdelivery'] = ['PRY'] * imp_df.shape[0] # 目的国国际编码
    target_tab['countryofdelivery'] = ['PARAGUAY'] * imp_df.shape[0] # 目的国英文名称
    
    target_tab['importername'] = imp_df['IMPORTER'] # 采购商名称
    # target_tab['importeraddress'] = imp_df['aaaaa'] # 采购商地址（暂未获取到对应字段）
    # target_tab['importercontact'] = imp_df['aaaaa'] # 采购商联系方式（暂未获取到对应字段）
    # target_tab['suppliername'] = imp_df['aaaaa'] # 供应商名称（暂未获取到对应字段）
    # target_tab['supplieraddress'] = imp_df['aaaaa'] # 供应商地址（暂未获取到对应字段）
    # target_tab['suppliercontact'] = imp_df['aaaaa'] # 供应商联系方式（暂未获取到对应字段）
    target_tab['hscode'] = imp_df['HS_CODE'] # hs编码
    # target_tab['hscodedescription'] = imp_df['HS_CODE_DESC'] # hs编码描述（已注释，待启用）
    target_tab['commoditydescription'] = [x.replace("\"", " ") if x is not None else x for x in
                                          imp_df['PRODUCT_DESC'].values] # 产品描述
    target_tab['totalcifvalue'] = imp_df['CIF'] # cif总价
    target_tab['totalfobvalue'] = imp_df['CIF'] - imp_df['FREIGHT'] # fob总价（CIF减去运费）
    target_tab['grossweight'] = imp_df['G_WEIGHT'] # 毛重
    target_tab['netweight'] = imp_df['N_WEIGHT'] # 净重
    target_tab['quantity'] = imp_df['QUANTITY'] # 数量
    target_tab['quantityunit'] = imp_df['UNIT_OF_QUANTITY'] # 数量单位
    # target_tab['teu'] = imp_df['aaaaa'] # TEU（暂未获取到对应字段）
    # target_tab['importer_forwarderagent'] = [0] * imp_df.shape[0] # 采购商货代公司标签（根据IMPORTER判断为0）
    # target_tab['supplier_forwarderagent'] = imp_df['aaaaa'] # 供应商货代公司标签（暂未获取到对应字段）
    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签

    
    # 待判定
    target_tab['abnormaldata'] = [0] * imp_df.shape[0] # 是否命中异常数据规则
    
    # target_tab['portofloading'] = imp_df['EXIT_PORT'] # 启运港（已注释，待启用）
    target_tab['portofloading'] = [''] * imp_df.shape[0] # 启运港（暂未获取到对应字段）
    target_tab['portofdestination'] = imp_df['CUSTOMS'] # 目的港
    # 国家需转换为标准英文国名
    # target_tab['loadingcountrycode'] = imp_df['ORIGIN_COUNTRY'] # 启运国国际编码
    # target_tab['loadingcountry'] = imp_df['ORIGIN_COUNTRY'] # 启运国英文名称
    
    # 需映射成统一枚举值
    target_tab['transportterm'] = imp_df['TRANS_TYPE'] # 运输方式
    # target_tab['tradeterm'] = imp_df['INCOTERMS'] # 成交方式（已注释，待映射）
    target_tab['brand'] = imp_df['BRAND'] # 品牌
    # target_tab['paymentterm'] = imp_df['aaaaa'] # 付款方式（暂未获取到对应字段）
    # target_tab['carrier'] = imp_df['aaaaa'] # 承运人名称（暂未获取到对应字段）
    # target_tab['containerno'] = imp_df['aaaaa'] # 集装箱箱号（暂未获取到对应字段）
    # target_tab['vesselname'] = imp_df['aaaaa'] # 船名（暂未获取到对应字段）
    
    target_tab['version'] = imp_df['version'] # 版本
    target_tab['country'] = imp_df['src_country'] # 国家（暂未获取到对应字段）
    target_tab['IMPORTER_ID'] = imp_df['IMPORTER_ID'] # 渠道采购商编码
    # target_tab['SUPPLIER_ID'] = imp_df['aaaaa'] # 渠道供应商编码（暂未获取到对应字段）
    target_tab['cif_currency'] = 'USD'                         # cif货币类型
    target_tab['fob_currency'] = 'USD'                         # fob货币类型
    
    end = time.time()
    logger.info(f'Import data mapping and cleaning takes {round((end - start) / 60, 2)} minutes')
    
    return target_tab.loc[:,config.target_cols]

def PRY_get_target_export(exp_path, src_cols):
    """
    巴拉圭 出口
    4	拉丁美洲	PARAGUAY	巴拉圭	PRY
    """
    start = time.time()
    
    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    exp_df = pd.read_csv(exp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {exp_df.columns.values}')
    
    target_tab = pd.DataFrame(columns=config.target_cols)
    
    target_tab['channelno'] = ['zdzj'] * exp_df.shape[0] # 渠道缩写
    # 为每条记录生成独立的UUID并去除横线
    target_tab['dataid']             = exp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = exp_df['iesign']                    # 进出口标志
    target_tab['datatype'] = ['D'] * exp_df.shape[0] # 提单关单标志
    target_tab['writeoffflag'] = ['o'] * exp_df.shape[0] # 冲销标志
    # target_tab['writeoffdataid'] = exp_df['aaaaa'] # 冲销记录主键（暂未获取到对应字段）
    # target_tab['outputdate'] = exp_df['REG_DATE'] # 日期
    target_tab['outputdate'] = pd.to_datetime(exp_df['REG_DATE'], format='mixed').dt.strftime('%Y-%m-%d').values  # 日期
    
    # 原产来源国需要再确认
    target_tab['origincountrycode']   = ['PRY'] * exp_df.shape[0]          # 原产国国际编码
    target_tab['origincountry']       = ['PARAGUAY'] * exp_df.shape[0]     # 原产国英文名称
    # 需要转写为标准英文国名
    target_tab['countrycodeofdelivery'] = exp_df['DEST_COUNTRY'] # 目的国国际编码
    target_tab['countryofdelivery'] = exp_df['DEST_COUNTRY'] # 目的国英文名称
    
    # target_tab['importername'] = exp_df['aaaaa'] # 采购商名称（暂未获取到对应字段）
    # target_tab['importeraddress'] = exp_df['aaaaa'] # 采购商地址（暂未获取到对应字段）
    # target_tab['importercontact'] = exp_df['aaaaa'] # 采购商联系方式（暂未获取到对应字段）
    target_tab['suppliername'] = exp_df['EXPORTER'] # 供应商名称
    # target_tab['supplieraddress'] = exp_df['aaaaa'] # 供应商地址（暂未获取到对应字段）
    # target_tab['suppliercontact'] = exp_df['aaaaa'] # 供应商联系方式（暂未获取到对应字段）
    target_tab['hscode'] = exp_df['HS_CODE'] # hs编码
    # target_tab['hscodedescription'] = exp_df['aaaaa'] # hs编码描述（暂未获取到对应字段）
    target_tab['commoditydescription'] = [x.replace("\"", " ") if x is not None else x for x in
                                          exp_df['PRODUCT_DESC'].values] # 产品描述
    target_tab['totalcifvalue'] = exp_df['CIF'] # cif总价
    target_tab['totalfobvalue'] = exp_df['FOB'] # fob总价
    target_tab['grossweight'] = exp_df['G_WEIGHT'] # 毛重
    target_tab['netweight'] = exp_df['N_WEIGHT'] # 净重
    target_tab['quantity'] = exp_df['QUANTITY'] # 数量
    target_tab['quantityunit'] = exp_df['UNIT_OF_QUANTITY'] # 数量单位
    # target_tab['teu'] = exp_df['aaaaa'] # TEU（暂未获取到对应字段）
    # target_tab['importer_forwarderagent'] = exp_df['aaaaa'] # 采购商货代公司标签（暂未获取到对应字段）
    # target_tab['supplier_forwarderagent'] = [0] * exp_df.shape[0] # 供应商货代公司标签（根据EXPORTER判断为0）
    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签

    
    # 待判定
    target_tab['abnormaldata'] = [0] * exp_df.shape[0] # 是否命中异常数据规则
    
    target_tab['portofloading'] = exp_df['CUSTOMS'] # 启运港
    # target_tab['portofdestination'] = exp_df['aaaaa'] # 目的港（暂未获取到对应字段）
    # 国家需转换为标准英文国名
    target_tab['loadingcountrycode'] = exp_df['TRANS_COUNTRY'] # 启运国国际编码
    target_tab['loadingcountry'] = exp_df['TRANS_COUNTRY'] # 启运国英文名称
    
    # 需映射成统一枚举值
    target_tab['transportterm'] = exp_df['TRANS_TYPE'] # 运输方式
    
    # 需映射成统一枚举值
    # target_tab['tradeterm'] = exp_df['INCOTERMS'] # 成交方式（已注释，待映射）
    target_tab['brand'] = exp_df['BRAND'] # 品牌
    # target_tab['paymentterm'] = exp_df['aaaaa'] # 付款方式（暂未获取到对应字段）
    # target_tab['carrier'] = exp_df['aaaaa'] # 承运人名称（暂未获取到对应字段）
    # target_tab['containerno'] = exp_df['aaaaa'] # 集装箱箱号（暂未获取到对应字段）
    # target_tab['vesselname'] = exp_df['aaaaa'] # 船名（暂未获取到对应字段）
    
    target_tab['version'] = exp_df['version'] # 版本
    target_tab['country'] = exp_df['src_country'] # 国家（暂未获取到对应字段）
    # target_tab['IMPORTER_ID'] = exp_df['aaaaa'] # 渠道采购商编码（暂未获取到对应字段）
    target_tab['SUPPLIER_ID'] = exp_df['EXPORTER_ID'] # 渠道供应商编码
    target_tab['cif_currency'] = 'USD'                         # cif货币类型
    target_tab['fob_currency'] = 'USD'                         # fob货币类型
    
    end = time.time()
    logger.info(f'Export data mapping and cleaning takes {round((end - start) / 60, 2)} minutes')
    
    return target_tab.loc[:,config.target_cols]


# 5
def PAN_get_target_import(imp_path, src_cols):
    """
    巴拿马 进口
    5	拉丁美洲	PANAMA	巴拿马	PAN
    """
    start=time.time()
    src_col_type = get_col_str_type(src_cols)
    imp_df = pd.read_csv(imp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {imp_df.columns.values}')
    
    target_tab = pd.DataFrame(columns=config.target_cols)
    
    target_tab['channelno'] = ['zdzj']*imp_df.shape[0]  # 渠道缩写
    target_tab['dataid']             = imp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = imp_df['iesign']                    # 进出口标志
    target_tab['writeoffflag'] = ['o']*imp_df.shape[0]  # 冲销标志
    target_tab['datatype'] = ['D'] * imp_df.shape[0]  # 提单关单标志: D关单
    
    target_tab['outputdate'] = [f'{int(x[0]):04d}-{int(x[1]):02d}-{int(x[2]):02d}' for x in     
                                imp_df.loc[:,['YEAR', 'MONTH', 'DAY']].values]  # 日期
    target_tab['origincountrycode'] = imp_df['ORIGIN_COUNTRY']  # 原产国国际编码
    target_tab['origincountry'] = imp_df['ORIGIN_COUNTRY']  # 原产国英文名称
    target_tab['countrycodeofdelivery'] = ['PAN'] * imp_df.shape[0]  # 目的国国际编码
    target_tab['countryofdelivery'] = ['PANAMA'] * imp_df.shape[0]  # 目的国英文名称
    
    target_tab['importername'] = imp_df['IMPORTER']  # 采购商名称
    #target_tab['importeraddress'] = ['']*imp_df.shape[0]  # 采购商地址
    #target_tab['importercontact'] = ['']*imp_df.shape[0]  # 采购商联系方式
    
    target_tab['suppliername'] = imp_df['EXPORTER']  # 供应商名称
    #target_tab['supplieraddress'] = ['']*imp_df.shape[0]  # 供应商地址
    #target_tab['suppliercontact'] = ['']*imp_df.shape[0]  # 供应商联系方式
    
    target_tab['hscode'] = imp_df['HS_CODE']  # hs编码
    #target_tab['hscodedescription'] = ['']*imp_df.shape[0]  # hs编码描述
    target_tab['commoditydescription'] = [x.replace("\"", " ") if x is not None else x for x in     
                                          imp_df['PRODUCT_DESC'].values]  # 产品描述
    target_tab['totalcifvalue'] = imp_df['CIF']  # cif总价
    target_tab['totalfobvalue'] = imp_df['FOB']  # fob总价
    
    target_tab['grossweight'] = imp_df['G_WEIGHT']  # 毛重
    target_tab['netweight'] = imp_df['N_WEIGHT']  # 重量
    target_tab['quantity'] = imp_df['QUANTITY']  # 数量
    target_tab['quantityunit'] = imp_df['UNIT_OF_QUANTITY']  # 数量单位
    #target_tab['teu'] = [0]*imp_df.shape[0]  # TEU
    
    # target_tab['importer_forwarderagent'] = [0] * imp_df.shape[0]  # 采购商货代公司标签
    #target_tab['supplier_forwarderagent'] = [0] * imp_df.shape[0]  # 供应商货代公司标签
    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签

    target_tab['abnormaldata'] = [0] * imp_df.shape[0]  # 是否命中异常数据规则
    
    target_tab['portofloading'] = imp_df['PORT']  # 启运港
    #target_tab['portofdestination'] = ['']*imp_df.shape[0]  # 目的港
    #target_tab['loadingcountrycode'] = ['']*imp_df.shape[0]  # 启运国国际编码
    #target_tab['loadingcountry'] = ['']*imp_df.shape[0]  # 启运国英文名称
    
    target_tab['transportterm'] = imp_df['TRANS_TYPE']  # 运输方式
    #target_tab['tradeterm'] = ['']*imp_df.shape[0]  # 成交方式
    #target_tab['paymentterm'] = ['']*imp_df.shape[0]  # 付款方式
    
    #target_tab['carrier'] = ['']*imp_df.shape[0]  # 承运人名称
    #target_tab['containerno'] = ['']*imp_df.shape[0]  # 集装箱箱号
    #target_tab['vesselname'] = ['']*imp_df.shape[0]  # 船名
    
    #target_tab['brand'] = ['']*imp_df.shape[0]  # 品牌
    target_tab['version'] = imp_df['version']  # 版本
    target_tab['country'] = imp_df['src_country']  # 国家
    
    target_tab['IMPORTER_ID'] = imp_df['IMPORTER_ID']  # 渠道采购商编码
    #target_tab['SUPPLIER_ID'] = ['']*imp_df.shape[0]  # 渠道供应商编码
    target_tab['cif_currency'] = 'USD'                         # cif货币类型
    target_tab['fob_currency'] = 'USD'                         # fob货币类型
    
    end=time.time()
    logger.info(f'Import data mapping and cleaning takes {round((end-start)/60,2)} minutes')
    
    return target_tab.loc[:,config.target_cols]

def PAN_get_target_export(exp_path, src_cols):
    """
    巴拿马 出口
    5	拉丁美洲	PANAMA	巴拿马	PAN
    """
    start=time.time()
    
    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    exp_df = pd.read_csv(exp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {exp_df.columns.values}')
    
    target_tab = pd.DataFrame(columns=config.target_cols)
    
    target_tab['channelno'] = ['zdzj'] * exp_df.shape[0]  # 渠道缩写
    target_tab['dataid']             = exp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = exp_df['iesign']                    # 进出口标志
    target_tab['datatype'] = ['D'] * exp_df.shape[0]  # 提单关单标志
    target_tab['writeoffflag'] = ['o'] * exp_df.shape[0]  # 冲销标志
    # target_tab['writeoffdataid'] = exp_df['writeoffdataid']  # 冲销记录主键
    target_tab['outputdate'] = [f'{int(x[0]):04d}-{int(x[1]):02d}-{int(x[2]):02d}' for x in     
                                exp_df.loc[:, ['YEAR', 'MONTH', 'DAY']].values]  # 日期
    target_tab['origincountrycode']   = ['PAN'] * exp_df.shape[0]          # 原产国国际编码
    target_tab['origincountry']       = ['PANAMA'] * exp_df.shape[0]     # 原产国英文名称
    target_tab['countrycodeofdelivery'] = exp_df['DEST_COUNTRY']  # 目的国国际编码
    target_tab['countryofdelivery'] = exp_df['DEST_COUNTRY']  # 目的国英文名称
    target_tab['importername'] = exp_df['IMPORTER']  # 采购商名称
    # target_tab['importeraddress'] = exp_df['importeraddress']  # 采购商地址
    # target_tab['importercontact'] = exp_df['importercontact']  # 采购商联系方式
    target_tab['suppliername'] = exp_df['EXPORTER']  # 供应商名称
    # target_tab['supplieraddress'] = exp_df['supplieraddress']  # 供应商地址
    # target_tab['suppliercontact'] = exp_df['suppliercontact']  # 供应商联系方式
    target_tab['hscode'] = exp_df['HS_CODE']  # hs编码
    # target_tab['hscodedescription'] = exp_df['hscodedescription']  # hs编码描述
    target_tab['commoditydescription'] = [x.replace("\"", " ") if x is not None else x for x in   
                                          exp_df['PRODUCT_DESC'].values]  # 产品描述
    # target_tab['totalcifvalue'] = exp_df['totalcifvalue']  # cif总价
    target_tab['totalfobvalue'] = exp_df['FOB']  # fob总价
    target_tab['grossweight'] = exp_df['G_WEIGHT']  # 毛重
    target_tab['netweight'] = exp_df['N_WEIGHT']  # 重量
    target_tab['quantity'] = exp_df['QUANTITY']  # 数量
    target_tab['quantityunit'] = exp_df['UNIT_OF_QUANTITY']  # 数量单位
    # target_tab['teu'] = exp_df['teu']  # TEU
    # target_tab['importer_forwarderagent'] = exp_df['importer_forwarderagent']  #  采购商货代公司标签
    # target_tab['supplier_forwarderagent'] = [0] * exp_df.shape[0]  # 供应商货代公司标签
    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签

    target_tab['abnormaldata'] = [0] * exp_df.shape[0]  # 是否命中异常数据规则
    target_tab['portofloading'] = exp_df['PORT']  # 启运港
    # target_tab['portofdestination'] = exp_df['portofdestination']  # 目的港
    # target_tab['loadingcountrycode'] = exp_df['loadingcountrycode']  # 启运国国际编码
    # target_tab['loadingcountry'] = exp_df['loadingcountry']  # 启运国英文名称
    target_tab['transportterm'] = exp_df['TRANS_TYPE']  # 运输方式
    # target_tab['tradeterm'] = exp_df['tradeterm']  # 成交方式
    # target_tab['paymentterm'] = exp_df['paymentterm']  # 付款方式
    # target_tab['carrier'] = exp_df['carrier']  # 承运人名称
    # target_tab['containerno'] = exp_df['containerno']  # 集装箱箱号
    # target_tab['vesselname'] = exp_df['vesselname']  # 船名
    # target_tab['brand'] = exp_df['brand']  # 品牌
    target_tab['version'] = exp_df['version']  # 版本
    target_tab['country'] = exp_df['src_country']  # 国家
    # target_tab['IMPORTER_ID'] = exp_df['IMPORTER_ID']  # 渠道采购商编码
    # target_tab['SUPPLIER_ID'] = exp_df['SUPPLIER_ID']  # 渠道供应商编码
    # target_tab['cif_currency'] = 'USD'                         # cif货币类型
    target_tab['fob_currency'] = 'USD'                         # fob货币类型
    
    end=time.time()
    logger.info(f'Export data mapping and cleaning takes {round((end-start)/60,2)} minutes')
    
    return target_tab.loc[:,config.target_cols]


# 6
def BWA_get_target_import(imp_path, src_cols):
    """
    博茨瓦纳 进口
    6   非洲  BOTSWANA    博茨瓦纳    BWA
    """
    start = time.time()
    src_col_type = get_col_str_type(src_cols)
    imp_df = pd.read_csv(imp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {imp_df.columns.values}')

    target_tab = pd.DataFrame(columns=config.target_cols)

    target_tab['channelno'] = ['zdzj'] * imp_df.shape[0]                    # 渠道缩写
    target_tab['dataid']             = imp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = imp_df['iesign']                    # 进出口标志
    target_tab['datatype'] = ['D'] * imp_df.shape[0]                        # 提单关单标志
    target_tab['writeoffflag'] = ['o'] * imp_df.shape[0]                    # 冲销标志
    # target_tab['writeoffdataid'] = imp_df['aaaaa']                          # 冲销记录主键

    target_tab['outputdate'] = [f'{int(x[0]):04d}-{int(x[1]):02d}-{int(x[2]):02d}' for x in imp_df.loc[:, ['YEAR', 'MONTH', 'DAY']].values]  # 日期
    target_tab['origincountrycode'] = imp_df['ORIGIN_COUNTRY']              # 原产国国际编码
    target_tab['origincountry'] = imp_df['ORIGIN_COUNTRY']                  # 原产国英文名称
    target_tab['countrycodeofdelivery'] = ['BWA'] * imp_df.shape[0]           # 目的国国际编码
    target_tab['countryofdelivery'] = ['BOTSWANA'] * imp_df.shape[0]               # 目的国英文名称
    target_tab['importername'] = imp_df['IMPORTER_NAME']                    # 采购商名称
    # target_tab['importeraddress'] = imp_df['aaaaa']                         # 采购商地址
    # target_tab['importercontact'] = imp_df['aaaaa']                         # 采购商联系方式
    target_tab['suppliername'] = imp_df['EXPORTER_NAME']                            # 供应商名称
    # target_tab['supplieraddress'] = imp_df['aaaaa']                          # 供应商地址
    # target_tab['suppliercontact'] = imp_df['aaaaa']                          # 供应商联系方式
    target_tab['hscode'] = imp_df['HS_CODE']                                # hs编码
    target_tab['hscodedescription'] = imp_df['HS_CODE_DESC']                # hs编码描述
    target_tab['commoditydescription'] = [str(x).replace("\"", " ") if x is not None else x for x in imp_df['PRODUCT_DESC'].values]  # 产品描述
    # target_tab['totalcifvalue'] = imp_df['TOTAL_FOB_VALUE_IN_USD']          # cif总价
    target_tab['totalfobvalue'] = imp_df['TOTAL_FOB_VALUE_IN_USD']                           # fob总价
    target_tab['grossweight'] = imp_df['G_WEIGHT_IN_KG']                    # 毛重
    target_tab['netweight'] = imp_df['N_WEIGHT_IN_KG']                      # 重量
    target_tab['quantity'] = imp_df['QUANTITY']                             # 数量
    target_tab['quantityunit'] = imp_df['UNIT_OF_QUANTITY']                 # 数量单位
    # target_tab['teu'] = imp_df['aaaaa']                                     # TEU
    # target_tab['importer_forwarderagent'] = [0] * imp_df.shape[0]           # 采购商货代公司标签
    # target_tab['supplier_forwarderagent'] = imp_df['aaaaa']                 # 供应商货代公司标签
    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签

    target_tab['abnormaldata'] = [0] * imp_df.shape[0]                      # 是否命中异常数据规则
    # target_tab['portofloading'] = imp_df['aaaaa']                           # 启运港
    target_tab['portofdestination'] = imp_df['DEST_PORT']                   # 目的港
    target_tab['loadingcountrycode'] = imp_df['SALES_COUNTRY']              # 启运国国际编码
    target_tab['loadingcountry'] = imp_df['SALES_COUNTRY']                  # 启运国英文名称
    # target_tab['transportterm'] = imp_df['aaaaa']                           # 运输方式
    # target_tab['tradeterm'] = imp_df['aaaaa']                               # 成交方式
    # target_tab['paymentterm'] = imp_df['aaaaa']                             # 付款方式
    # target_tab['carrier'] = imp_df['aaaaa']                                 # 承运人名称
    # target_tab['containerno'] = imp_df['aaaaa']                             # 集装箱箱号
    # target_tab['vesselname'] = imp_df['aaaaa']                              # 船名
    # target_tab['brand'] = imp_df['aaaaa']                                   # 品牌
    target_tab['version'] = imp_df['version']                                 # 版本
    target_tab['country'] = imp_df['src_country']                                 # 国家
    target_tab['IMPORTER_ID'] = imp_df['IMPORTER_NAME']                     # 渠道采购商编码
    # target_tab['SUPPLIER_ID'] = imp_df['aaaaa']                             # 渠道供应商编码
    # target_tab['cif_currency'] = 'USD'                         # cif货币类型
    target_tab['fob_currency'] = 'USD'                         # fob货币类型
    
    end = time.time()
    logger.info(f'Import data mapping and cleaning takes {round((end-start)/60,2)} minutes')
    return target_tab.loc[:,config.target_cols]

def BWA_get_target_export(exp_path, src_cols):
    """
    博茨瓦纳 出口
    6   非洲  BOTSWANA    博茨瓦纳    BWA
    """
    start = time.time()
    
    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    exp_df = pd.read_csv(exp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {exp_df.columns.values}')

    target_tab = pd.DataFrame(columns=config.target_cols)

    target_tab['channelno']           = ['zdzj'] * exp_df.shape[0]         # 渠道缩写
    target_tab['dataid']             = exp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = exp_df['iesign']                    # 进出口标志
    target_tab['datatype']            = ['D'] * exp_df.shape[0]            # 提单关单标志
    target_tab['writeoffflag']        = ['o'] * exp_df.shape[0]            # 冲销标志
    # target_tab['writeoffdataid']      = exp_df['aaaaa']                    # 冲销记录主键

    target_tab['outputdate'] = [f'{int(x[0]):04d}-{int(x[1]):02d}-{int(x[2]):02d}' for x in exp_df.loc[:, ['YEAR', 'MONTH', 'DAY']].values]  # 日期
    target_tab['origincountrycode']   = ['BWA'] * exp_df.shape[0]          # 原产国国际编码
    target_tab['origincountry']       = ['BOTSWANA'] * exp_df.shape[0]     # 原产国英文名称
    target_tab['countrycodeofdelivery'] = exp_df['DEST_COUNTRY']           # 目的国国际编码
    target_tab['countryofdelivery']   = exp_df['DEST_COUNTRY']             # 目的国英文名称
    target_tab['importername']        = exp_df['IMPORTER_NAME']                    # 采购商名称
    # target_tab['importeraddress']     = exp_df['aaaaa']                    # 采购商地址
    # target_tab['importercontact']     = exp_df['aaaaa']                    # 采购商联系方式
    target_tab['suppliername']        = exp_df['EXPORTER_NAME']            # 供应商名称
    # target_tab['supplieraddress']     = exp_df['aaaaa']                    # 供应商地址
    # target_tab['suppliercontact']     = exp_df['aaaaa']                    # 供应商联系方式
    target_tab['hscode']              = exp_df['HS_CODE']                  # hs编码
    target_tab['hscodedescription']   = exp_df['HS_CODE_DESC']             # hs编码描述
    target_tab['commoditydescription'] = [str(x).replace("\"", " ") if x is not None else x for x in exp_df['PRODUCT_DESC'].values]  # 产品描述
    # target_tab['totalcifvalue']       = exp_df['aaaaa']                    # cif总价
    target_tab['totalfobvalue']       = exp_df['ITEM_FOB_IN_USD']          # fob总价
    target_tab['grossweight']         = exp_df['G_WEIGHT_IN_KG']           # 毛重
    target_tab['netweight']           = exp_df['N_WEIGHT_IN_KG']           # 重量
    target_tab['quantity']            = exp_df['QUANTITY']                 # 数量
    target_tab['quantityunit']        = exp_df['UNIT_OF_QUANTITY']         # 数量单位
    # target_tab['teu']                 = exp_df['aaaaa']                    # TEU
    # target_tab['importer_forwarderagent'] = exp_df['aaaaa']                # 采购商货代公司标签
    # target_tab['supplier_forwarderagent'] = [0] * exp_df.shape[0]          # 供应商货代公司标签
    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签

    target_tab['abnormaldata']        = [0] * exp_df.shape[0]              # 是否命中异常数据规则
    target_tab['portofloading']       = exp_df['CUSTOMS_OFFICE_NAME(CLEARANCE)']  # 启运港
    # target_tab['portofdestination']   = exp_df['aaaaa']                    # 目的港
    target_tab['loadingcountrycode']  = ['BWA'] * exp_df.shape[0]          # 启运国国际编码
    target_tab['loadingcountry']      = ['BOTSWANA'] * exp_df.shape[0]     # 启运国英文名称
    # target_tab['transportterm']       = exp_df['aaaaa']                    # 运输方式
    # target_tab['tradeterm']           = exp_df['aaaaa']                    # 成交方式
    # target_tab['paymentterm']         = exp_df['aaaaa']                    # 付款方式
    # target_tab['carrier']             = exp_df['aaaaa']                    # 承运人名称
    # target_tab['containerno']         = exp_df['aaaaa']                    # 集装箱箱号
    # target_tab['vesselname']          = exp_df['aaaaa']                    # 船名
    # target_tab['brand']               = exp_df['aaaaa']                    # 品牌
    target_tab['version']             = exp_df['version']                    # 版本
    target_tab['country']             = exp_df['src_country']                    # 国家
    # target_tab['IMPORTER_ID']         = exp_df['aaaaa']                    # 渠道采购商编码
    target_tab['SUPPLIER_ID']         = exp_df['EXPORTER_NAME']            # 渠道供应商编码
    # target_tab['cif_currency'] = 'USD'                         # cif货币类型
    target_tab['fob_currency'] = 'USD'                         # fob货币类型

    end = time.time()
    logger.info(f'Export data mapping and cleaning takes {round((end-start)/60,2)} minutes')
    return target_tab.loc[:,config.target_cols]


# 7
def RUS_get_target_tab(imp_path, src_cols):
    """
    7 俄罗斯联邦 进口
    欧洲	RUSSIA	俄罗斯联邦	RUS
    """
    start=time.time()
    src_col_type = get_col_str_type(src_cols)
    imp_df = pd.read_csv(imp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {imp_df.columns.values}')

    target_tab = pd.DataFrame(columns=config.target_cols)

    target_tab['channelno'] = ['zdzj']*imp_df.shape[0] # 渠道缩写
    target_tab['dataid']             = imp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = imp_df['iesign']                    # 进出口标志
    target_tab['datatype'] = ['D'] * imp_df.shape[0] # 提单关单标志
    target_tab['writeoffflag'] = ['o']*imp_df.shape[0] # 冲销标志
    # target_tab['writeoffdataid'] = imp_df['aaa'] # 冲销记录主键

    target_tab['outputdate'] =  pd.to_datetime(imp_df['Registration date'], format='mixed').dt.strftime('%Y-%m-%d').values # 日期
    target_tab['origincountrycode'] = ['RUS' if x[0]=='E' else x[1] for x in imp_df.loc[:, ['iesign', 'Name of Consignee by EGRPO']].values] # 原产国国际编码
    target_tab['origincountry'] = ['RUSSIA' if x[0]=='E' else x[1] for x in imp_df.loc[:, ['iesign', 'Name of Consignee by EGRPO']].values] # 原产国英文名称
    target_tab['countrycodeofdelivery'] = ['RUS' if x[0]=='I' else x[1] for x in imp_df.loc[:, ['iesign', 'Country of destination']].values] # 目的国国际编码
    target_tab['countryofdelivery'] = ['RUSSIA' if x[0]=='I' else x[1] for x in imp_df.loc[:, ['iesign', 'Country of destination']].values] # 目的国英文名称
    target_tab['importername'] = imp_df['Name of Consignee by EGRPO'] # 采购商名称
    target_tab['importeraddress'] = imp_df['Name of Consignee by EGRPO'] # 采购商地址
    target_tab['importercontact'] = imp_df['Name of Consignee by EGRPO'] # 采购商联系方式
    target_tab['suppliername'] = imp_df['Consignor name of EGRPO'] # 供应商名称
    target_tab['supplieraddress'] = imp_df['Consignor name of EGRPO'] # 供应商地址
    target_tab['suppliercontact'] = imp_df['Consignor name of EGRPO'] # 供应商联系方式
    target_tab['hscode'] = imp_df['Cargo code'] # hs编码
    target_tab['hscodedescription'] = imp_df['Name of Cargo'] # hs编码描述
    target_tab['commoditydescription'] = imp_df['Full name of cargo'] # 产品描述
    # target_tab['totalcifvalue'] = imp_df['aaaaa'] # cif总价
    # target_tab['totalfobvalue'] = imp_df['aaaaa'] # fob总价
    target_tab['grossweight'] = imp_df['Traffic volume kg'] # 毛重
    # target_tab['netweight'] = imp_df['aaaaa'] # 重量
    # target_tab['quantity'] = imp_df['aaaaa'] # 数量
    # target_tab['quantityunit'] = imp_df['aaaaa'] # 数量单位 
    # target_tab['teu'] = imp_df['aaaaa'] # TEU
    # target_tab['importer_forwarderagent'] = imp_df['aaaaa'] # 采购商货代公司标签
    # target_tab['supplier_forwarderagent'] = imp_df['aaaaa'] # 供应商货代公司标签
    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签

    target_tab['abnormaldata'] = [0 if x in ['Импорт','Экспорт'] else 1 for x in imp_df['Type of transportation'].values] # 是否命中异常数据规则
    target_tab['portofloading'] = imp_df['Departure station of CIS'] # 启运港
    target_tab['portofdestination'] = imp_df['Station of destination'] # 目的港
    target_tab['loadingcountrycode'] = imp_df['Country of departure'] # 启运国国际编码
    # target_tab['loadingcountry'] = imp_df['aaaaa'] # 启运国英文名称
    # target_tab['transportterm'] = imp_df['aaaaa'] # 运输方式
    # target_tab['tradeterm'] = imp_df['aaaaa'] # 成交方式
    # target_tab['paymentterm'] = imp_df['aaaaa'] # 付款方式
    # target_tab['carrier'] = imp_df['aaaaa'] # 承运人名称
    target_tab['containerno'] = imp_df['Container number'] # 集装箱箱号
    # target_tab['vesselname'] = imp_df['aaaaa'] # 船名
    # target_tab['brand'] = imp_df['aaaaa'] # 品牌
    target_tab['version'] = imp_df['version'] # 版本
    target_tab['country'] = imp_df['src_country'] # 国家
    # target_tab['IMPORTER_ID'] = imp_df['aaaaa'] # 渠道采购商编码
    # target_tab['SUPPLIER_ID'] = imp_df['aaaaa'] # 渠道供应商编码
    # target_tab['cif_currency'] = 'USD'                         # cif货币类型
    # target_tab['fob_currency'] = 'USD'                         # fob货币类型

    end=time.time()
    logger.info(f'Import data mapping and cleaning takes {round((end-start)/60,2)} minutes')

    return target_tab.loc[:,config.target_cols]


# 8
def ECU_get_target_import(imp_path, src_cols):
    """
    厄瓜多尔 进口
    8	拉丁美洲	ECUADOR	厄瓜多尔	ECU
    """
    start = time.time()
    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    imp_df = pd.read_csv(imp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {imp_df.columns.values}')
    
    target_tab = pd.DataFrame(columns=config.target_cols)
    
    # 基础字段
    target_tab['channelno'] = ['zdzj'] * imp_df.shape[0]  # 渠道编号
    target_tab['dataid']             = imp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = imp_df['iesign']                    # 进出口标志
    target_tab['writeoffflag'] = ['o'] * imp_df.shape[0]  # 核销标志
    target_tab['datatype'] = ['D'] * imp_df.shape[0]  # 数据类型
    
    # ----------------------------------------------------
    # 1. 基本信息
    target_tab['outputdate'] = pd.to_datetime(imp_df['REG_DATE'], format='mixed').dt.strftime('%Y-%m-%d').values  # 到达日期
    
    # 2. 国家信息（需要转写为标准英文国名）
    target_tab['origincountrycode'] = imp_df['ORIGIN_COUNTRY']  # 原产国
    target_tab['origincountry'] = imp_df['ORIGIN_COUNTRY']  # 原产国
    target_tab['countrycodeofdelivery'] = ['ECU'] * imp_df.shape[0]  # 目的国
    target_tab['countryofdelivery'] = ['ECUADOR'] * imp_df.shape[0]  # 目的国
    target_tab['loadingcountrycode'] = imp_df['SHIPPING_COUNTRY']  # 发货国（需转标准英文）
    target_tab['loadingcountry'] = imp_df['SHIPPING_COUNTRY']  # 发货国（需转标准英文）
    
    # 3. 贸易方信息
    target_tab['importername'] = imp_df['IMPORTER']  # 进口商
    # target_tab['suppliername'] = imp_df['SHIPPER']  # 托运人
    target_tab['IMPORTER_ID'] = imp_df['IMPORTER_ID']  # 进口商ID
    
    # 4. 产品信息
    target_tab['hscode'] = imp_df['HS_CODE']  # HS编码
    target_tab['hscodedescription'] = imp_df['HS_CODE_DESC']  # HS编码描述
    target_tab['commoditydescription'] = [str(x).replace("\"", " ") if x is not None else x for x in
                                          imp_df['PRODUCT_DESC'].values]  # 产品描述（处理引号）
    
    # 5. 价值重量信息
    target_tab['totalcifvalue'] = imp_df['CIF']  # CIF价值
    target_tab['totalfobvalue'] = imp_df['FOB']  # FOB价值
    target_tab['netweight'] = imp_df['N_WEIGHT']  # 净重
    target_tab['quantity'] = imp_df['QUANTITY']  # 数量
    target_tab['quantityunit'] = imp_df['UNIT_OF_QUANTITY']  # 数量单位
    
    # 6. 运输信息
    # target_tab['importer_forwarderagent'] = [0] * imp_df.shape[0]  # 进口商代理（待判断）
    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签

    target_tab['abnormaldata'] = [0] * imp_df.shape[0]  # 异常数据（待判定）
    target_tab['portofloading'] = imp_df['PORT']  # 港口
    target_tab['transportterm'] = imp_df['TRANS_TYPE']  # 运输方式（需映射成统一枚举值）
    # target_tab['carrier'] = imp_df['SHIPPER']  # 运输公司
    target_tab['carrier'] = imp_df['TRANS_CORP']  # 运输公司
    target_tab['containerno'] = imp_df['CONTAINER']  # 集装箱号
    target_tab['vesselname'] = imp_df['SHIP_NAME']  # 船名
    target_tab['brand'] = imp_df['BRAND']  # 品牌
    
    target_tab['country'] = imp_df['src_country'] # 国家
    target_tab['version'] = imp_df['version'] # 版本
    target_tab['cif_currency'] = 'USD'                         # cif货币类型
    target_tab['fob_currency'] = 'USD'                         # fob货币类型
    
    end = time.time()
    logger.info(f'Import data mapping and cleaning takes {round((end - start) / 60, 2)} minutes')
    return target_tab.loc[:,config.target_cols]

def ECU_get_target_export(exp_path, src_cols):
    """
    厄瓜多尔 出口
    8	拉丁美洲	ECUADOR	厄瓜多尔	ECU
    """
    start = time.time()
    
    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    exp_df = pd.read_csv(exp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {exp_df.columns.values}')
    
    target_tab = pd.DataFrame(columns=config.target_cols)
    
    # 基础字段
    target_tab['channelno'] = ['zdzj'] * exp_df.shape[0]  # 渠道编号
    target_tab['dataid']             = exp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = exp_df['iesign']                    # 进出口标志
    target_tab['writeoffflag'] = ['o'] * exp_df.shape[0]  # 核销标志
    target_tab['datatype'] = ['D'] * exp_df.shape[0]  # 数据类型
    
    # ----------------------------------------------------
    # 1. 基本信息
    target_tab['outputdate'] = pd.to_datetime(exp_df['REG_DATE'], format='mixed').dt.strftime('%Y-%m-%d').values  # 登记日期
    
    # 2. 国家信息
    target_tab['origincountrycode']   = ['ECU'] * exp_df.shape[0]           # 原产国国际编码
    target_tab['origincountry']       = ['ECUADOR'] * exp_df.shape[0]    # 原产国英文名称
    target_tab['countrycodeofdelivery'] = exp_df['DEST_COUNTRY']  # 目的国
    target_tab['countryofdelivery'] = exp_df['DEST_COUNTRY']  # 目的国
    
    # 3. 贸易方信息
    target_tab['importername'] = exp_df['CONSIGNEE']  # 收货人
    target_tab['suppliername'] = exp_df['EXPORTER']  # 出口商
    target_tab['SUPPLIER_ID'] = exp_df['EXPORTER_ID']  # 出口商ID
    
    # 4. 产品信息
    target_tab['hscode'] = exp_df['HS_CODE']  # HS编码
    target_tab['hscodedescription'] = exp_df['HS_CODE_DESC']  # HS编码描述
    target_tab['commoditydescription'] = [str(x).replace("\"", " ") if x is not None else x for x in
                                          exp_df['PRODUCT_DESC'].values]  # 产品描述（处理引号）
    
    # 5. 价值重量信息
    target_tab['totalfobvalue'] = exp_df['FOB']  # FOB价值
    target_tab['netweight'] = exp_df['N_WEIGHT']  # 净重
    target_tab['quantity'] = exp_df['QUANTITY']  # 数量
    target_tab['quantityunit'] = exp_df['UNIT_OF_QUANTITY']  # 数量单位
    
    # 6. 运输信息
    # target_tab['importer_forwarderagent'] = [0] * exp_df.shape[0]  # 进口商代理（待判断）
    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签

    target_tab['abnormaldata'] = [0] * exp_df.shape[0]  # 异常数据（待判定）
    target_tab['portofdestination'] = exp_df['PORT']  # 港口
    target_tab['transportterm'] = exp_df['TRANS_TYPE']  # 运输方式
    target_tab['carrier'] = exp_df['TRANS_CORP']  # 运输公司
    target_tab['containerno'] = exp_df['CONTAINER']  # 集装箱号
    target_tab['vesselname'] = exp_df['SHIP_NAME']  # 船名
    
    target_tab['country'] = exp_df['src_country'] # 国家
    target_tab['version'] = exp_df['version'] # 版本
    # target_tab['cif_currency'] = 'USD'                         # cif货币类型
    target_tab['fob_currency'] = 'USD'                         # fob货币类型
    
    end = time.time()
    logger.info(f'Export data mapping and cleaning takes {round((end - start) / 60, 2)} minutes')
    return target_tab.loc[:,config.target_cols]


# 9
def PHL_get_target_import(imp_path, src_cols):
    """
    菲律宾 进口
    9	亚洲	PHILIPPINES	菲律宾	PHL
    """
    start = time.time()
    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    imp_df = pd.read_csv(imp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {imp_df.columns.values}')
    
    target_tab = pd.DataFrame(columns=config.target_cols)
    
    target_tab['channelno'] = ['zdzj'] * imp_df.shape[0] # 渠道缩写
    target_tab['dataid']             = imp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = imp_df['iesign']                    # 进出口标志
    target_tab['datatype'] = ['D'] * imp_df.shape[0] # 提单关单标志
    target_tab['writeoffflag'] = ['o'] * imp_df.shape[0] # 冲销标志
    # target_tab['writeoffdataid'] = imp_df['aaaaa'] # 冲销记录主键（暂未获取到对应字段）
    target_tab['outputdate'] = [f'{int(x[0]):04d}-{int(x[1]):02d}-{int(x[2]):02d}' for x in
                                imp_df.loc[:, ['YEAR', 'MONTH', 'DAY']].values] # 日期
    
    # 需要转写为标准英文国名
    target_tab['origincountrycode'] = imp_df['ORIGIN_COUNTRY'] # 原产国国际编码
    target_tab['origincountry'] = imp_df['ORIGIN_COUNTRY'] # 原产国英文名称
    target_tab['countrycodeofdelivery'] = ['PHL'] * imp_df.shape[0] # 目的国国际编码
    target_tab['countryofdelivery'] = ['PHILIPPINES'] * imp_df.shape[0] # 目的国英文名称
    
    target_tab['importername'] = imp_df['IMPORTER_NAME'] # 采购商名称
    target_tab['importeraddress'] = imp_df['IMPORTER_ADDRESS'] # 采购商地址
    target_tab['importercontact'] = imp_df['IMPORTER_PHONE'] # 采购商联系方式
    target_tab['suppliername'] = imp_df['EXPORTER_NAME'] # 供应商名称（暂未获取到对应字段）
    # target_tab['supplieraddress'] = imp_df['aaaaa'] # 供应商地址（暂未获取到对应字段）
    # target_tab['suppliercontact'] = imp_df['aaaaa'] # 供应商联系方式（暂未获取到对应字段）
    target_tab['hscode'] = imp_df['HS_CODE'] # hs编码
    # target_tab['hscodedescription'] = imp_df['HS_CODE_DESC'] # hs编码描述（已注释，待启用）
    target_tab['commoditydescription'] = [str(x).replace("\"", " ") if x is not None else x for x in
                                          imp_df['PRODUCT_DESC'].values] # 产品描述
    target_tab['totalcifvalue'] = imp_df['CIF_IN_FC'] # cif总价
    target_tab['totalfobvalue'] = imp_df['FOB_IN_FC'] # fob总价
    
    target_tab['grossweight'] = imp_df['G_WEIGHT'] # 毛重
    target_tab['netweight'] = imp_df['N_WEIGHT'] # 重量
    target_tab['quantity'] = imp_df['QUANTITY'] # 数量
    target_tab['quantityunit'] = imp_df['UNIT_OF_QUANTITY'] # 数量单位
    # target_tab['teu'] = imp_df['aaaaa'] # TEU（暂未获取到对应字段）
    # target_tab['importer_forwarderagent'] = [0] * imp_df.shape[0] # 采购商货代公司标签（根据IMPORTER判断为0）
    # target_tab['supplier_forwarderagent'] = imp_df['aaaaa'] # 供应商货代公司标签（暂未获取到对应字段）
    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签

    target_tab['abnormaldata'] = [0] * imp_df.shape[0] # 是否命中异常数据规则（待判定）
    
    # target_tab['portofloading'] = imp_df['EXIT_PORT'] # 启运港（已注释，待启用）
    target_tab['portofdestination'] = imp_df['PORT_OF_CLEARANCE'] # 目的港
    target_tab['loadingcountrycode'] = imp_df['EXPORT_COUNTRY'] # 启运国国际编码
    target_tab['loadingcountry'] = imp_df['EXPORT_COUNTRY'] # 启运国英文名称
    # target_tab['transportterm'] = imp_df['TRANS_TYPE'] # 运输方式（需映射成统一枚举值）
    # target_tab['tradeterm'] = imp_df['INCOTERMS'] # 成交方式（需映射成统一枚举值）
    # target_tab['paymentterm'] = imp_df['aaaaa'] # 付款方式（暂未获取到对应字段）
    # target_tab['carrier'] = imp_df['aaaaa'] # 承运人名称（暂未获取到对应字段）
    # target_tab['containerno'] = imp_df['aaaaa'] # 集装箱箱号（暂未获取到对应字段）
    # target_tab['vesselname'] = imp_df['aaaaa'] # 船名（暂未获取到对应字段）
    # target_tab['brand'] = imp_df['BRAND'] # 品牌（需映射成统一枚举值）
    target_tab['version'] = imp_df['version'] # 版本
    target_tab['country'] = imp_df['src_country'] # 国家（暂未获取到对应字段）
    # target_tab['IMPORTER_ID'] = imp_df['IMPORTER_ID'] # 渠道采购商编码（已注释，待启用）
    # target_tab['SUPPLIER_ID'] = imp_df['aaaaa'] # 渠道供应商编码（暂未获取到对应字段）
    target_tab['cif_currency'] = imp_df['FOREIGN_CURRENCY']                         # cif货币类型
    target_tab['fob_currency'] = imp_df['FOREIGN_CURRENCY']                         # fob货币类型 
    
    end = time.time()
    logger.info(f'Import data mapping and cleaning takes {round((end - start) / 60, 2)} minutes')
    
    return target_tab.loc[:,config.target_cols]

def PHL_get_target_export(exp_path, src_cols):
    """
    菲律宾 出口
    9	亚洲	PHILIPPINES	菲律宾	PHL
    """
    start = time.time()
    
    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    exp_df = pd.read_csv(exp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {exp_df.columns.values}')
    
    target_tab = pd.DataFrame(columns=config.target_cols)
    
    target_tab['channelno'] = ['zdzj'] * exp_df.shape[0] # 渠道缩写
    # 为每条记录生成独立的UUID并去除横线
    target_tab['dataid']             = exp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = exp_df['iesign']                    # 进出口标志
    target_tab['datatype'] = ['D'] * exp_df.shape[0] # 提单关单标志
    target_tab['writeoffflag'] = ['o'] * exp_df.shape[0] # 冲销标志
    # target_tab['writeoffdataid'] = exp_df['aaa'] # 冲销记录主键
    target_tab['outputdate'] = [f'{int(x[0]):04d}-{int(x[1]):02d}-{int(x[2]):02d}' for x in
                                exp_df.loc[:, ['YEAR', 'MONTH', 'DAY']].values] # 日期
    
    # 需要转写为标准英文国名
    target_tab['origincountrycode']   = ['PHL'] * exp_df.shape[0]           # 原产国国际编码
    target_tab['origincountry']       = ['PHILIPPINES'] * exp_df.shape[0]    # 原产国英文名称
    target_tab['countrycodeofdelivery'] = exp_df['DEST_COUNTRY'] # 目的国国际编码
    target_tab['countryofdelivery'] = exp_df['DEST_COUNTRY'] # 目的国英文名称
    
    target_tab['importername'] = exp_df['IMPORTER_NAME'] # 采购商名称（暂未获取到对应字段）
    # target_tab['importeraddress'] = exp_df['aaaaa'] # 采购商地址（暂未获取到对应字段）
    # target_tab['importercontact'] = exp_df['aaaaa'] # 采购商联系方式（暂未获取到对应字段）
    target_tab['suppliername'] = exp_df['EXPORTER_NAME'] # 供应商名称
    target_tab['supplieraddress'] = exp_df['EXPORTER_ADDRESS'] # 供应商地址
    # target_tab['suppliercontact'] = exp_df['aaaaa'] # 供应商联系方式（暂未获取到对应字段）
    target_tab['hscode'] = exp_df['HS_CODE'] # hs编码
    # target_tab['hscodedescription'] = exp_df['aaaaa'] # hs编码描述（暂未获取到对应字段）
    target_tab['commoditydescription'] = [str(x).replace("\"", " ") if x is not None else x for x in
                                          exp_df['PRODUCT_DESC'].values] # 产品描述
    # target_tab['totalcifvalue'] = exp_df['FOB_IN_FC']  # cif总价
    target_tab['totalfobvalue'] = exp_df['FOB_IN_FC'] # fob总价
    target_tab['grossweight'] = exp_df['G_WEIGHT'] # 毛重
    target_tab['netweight'] = exp_df['N_WEIGHT'] # 重量
    target_tab['quantity'] = exp_df['PACKAGES'] # 数量
    target_tab['quantityunit'] = exp_df['TYPE_OF_PACKAGE'] # 数量单位
    # target_tab['teu'] = exp_df['aaaaa'] # TEU（暂未获取到对应字段）
    # target_tab['importer_forwarderagent'] = exp_df['aaaaa'] # 采购商货代公司标签（暂未获取到对应字段）
    # target_tab['supplier_forwarderagent'] = [0] * exp_df.shape[0] # 供应商货代公司标签（根据EXPORTER判断为0）
    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签

    target_tab['abnormaldata'] = [0] * exp_df.shape[0] # 是否命中异常数据规则（待判定）
    target_tab['portofloading'] = exp_df['PORT_OF_CLEARANCE'] # 启运港
    # target_tab['portofdestination'] = exp_df['aaaaa'] # 目的港（暂未获取到对应字段）
    target_tab['loadingcountrycode'] = ['PHL'] * exp_df.shape[0] # 启运国国际编码
    target_tab['loadingcountry'] = ['PHILIPPINES'] * exp_df.shape[0] # 启运国英文名称
    # target_tab['transportterm'] = exp_df['TRANS_TYPE'] # 运输方式（需映射成统一枚举值）
    # target_tab['tradeterm'] = exp_df['INCOTERMS'] # 成交方式（需映射成统一枚举值）
    # target_tab['paymentterm'] = exp_df['aaaaa'] # 付款方式（暂未获取到对应字段）
    # target_tab['carrier'] = exp_df['aaaaa'] # 承运人名称（暂未获取到对应字段）
    # target_tab['containerno'] = exp_df['aaaaa'] # 集装箱箱号（暂未获取到对应字段）
    # target_tab['vesselname'] = exp_df['aaaaa'] # 船名（暂未获取到对应字段）
    # target_tab['brand'] = exp_df['BRAND'] # 品牌（需映射成统一枚举值）
    target_tab['version'] = exp_df['version'] # 版本
    target_tab['country'] = exp_df['src_country'] # 国家（暂未获取到对应字段）
    # target_tab['IMPORTER_ID'] = exp_df['aaaaa'] # 渠道采购商编码（暂未获取到对应字段）
    # target_tab['SUPPLIER_ID'] = exp_df['aaaaa'] # 渠道供应商编码（暂未获取到对应字段）
    # target_tab['cif_currency'] = imp_df['FOREIGN_CURRENCY']                         # cif货币类型
    target_tab['fob_currency'] = exp_df['FOREIGN_CURRENCY']                         # fob货币类型 
    
    end = time.time()
    logger.info(f'Export data mapping and cleaning takes {round((end - start) / 60, 2)} minutes')
    
    return target_tab.loc[:,config.target_cols]


# 10
def COL_get_target_import(imp_path, src_cols):
    """
    哥伦比亚 进口
    10	拉丁美洲	COLOMBIA	哥伦比亚	COL
    """
    start = time.time()
    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    imp_df = pd.read_csv(imp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {imp_df.columns.values}')
    
    target_tab = pd.DataFrame(columns=config.target_cols)
    
    target_tab['channelno'] = ['zdzj'] * imp_df.shape[0] # 渠道缩写
    target_tab['dataid']             = imp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = imp_df['iesign']                    # 进出口标志
    target_tab['datatype'] = ['D'] * imp_df.shape[0] # 提单关单标志
    target_tab['writeoffflag'] = ['o'] * imp_df.shape[0] # 冲销标志
    # target_tab['writeoffdataid'] = imp_df['aaaaa'] # 冲销记录主键（暂未获取到对应字段）
    target_tab['outputdate'] = [f'{int(x[0]):04d}-{int(x[1]):02d}-{int(x[2]):02d}' for x in
                                imp_df.loc[:, ['YEAR', 'MONTH', 'DAY']].values] # 日期
    
    # 原产国相关
    target_tab['origincountrycode'] = imp_df['ORIGIN_COUNTRY'] # 原产国国际编码
    target_tab['origincountry'] = imp_df['ORIGIN_COUNTRY'] # 原产国英文名称
    # 目的国相关
    target_tab['countrycodeofdelivery'] = ['COL'] * imp_df.shape[0] # 目的国国际编码
    target_tab['countryofdelivery'] = ['COLOMBIA'] * imp_df.shape[0] # 目的国英文名称
    
    # 采购商相关
    target_tab['importername'] = imp_df['IMPORTER'] # 采购商名称
    target_tab['importeraddress'] = imp_df['IMPORTER_ADDRESS'] # 采购商地址
    target_tab['importercontact'] = imp_df['IMPORTER_TEL'] # 采购商联系方式
    # 供应商相关
    target_tab['suppliername'] = imp_df['EXPORTER'] # 供应商名称
    target_tab['supplieraddress'] = imp_df['EXPORTER_ADDRESS'] # 供应商地址
    target_tab['suppliercontact'] = imp_df['EXPORTER_CONTACT'] # 供应商联系方式
    # 商品编码及描述
    target_tab['hscode'] = imp_df['HS_CODE'] # hs编码
    # target_tab['hscodedescription'] = imp_df['HS_CODE_DESC'] # hs编码描述（已注释，待启用）
    target_tab['commoditydescription'] = [str(x).replace("\"", " ") if x is not None else x for x in
                                          imp_df['PRODUCT_DESC'].values] # 产品描述
    # 价值相关
    target_tab['totalcifvalue'] = imp_df['CIF'] # cif总价
    target_tab['totalfobvalue'] = imp_df['FOB'] # fob总价
    # 重量相关
    # target_tab['grossweight'] = imp_df['G_WEIGHT'] # 毛重（已注释，待启用）
    target_tab['netweight'] = imp_df['N_WEIGHT'] # 净重
    # 数量相关
    target_tab['quantity'] = imp_df['QUANTITY'] # 数量
    target_tab['quantityunit'] = imp_df['UNIT_OF_QUANTITY'] # 数量单位
    # TEU（模板存在，当前缺失）
    # target_tab['teu'] = imp_df['aaaaa'] # TEU（暂未获取到对应字段）
    # 货代相关
    # target_tab['importer_forwarderagent'] = [0] * imp_df.shape[0] # 采购商货代公司标签（根据IMPORTER判断为0）
    # target_tab['supplier_forwarderagent'] = imp_df['aaaaa'] # 供应商货代公司标签（暂未获取到对应字段）
    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签

    # 异常数据标志
    target_tab['abnormaldata'] = [0] * imp_df.shape[0] # 是否命中异常数据规则（待判定）
    # 港口相关
    # target_tab['portofloading'] = imp_df['EXIT_PORT'] # 启运港（已注释，待启用）
    target_tab['portofdestination'] = imp_df['CUSTOMS'] # 目的港
    # 启运国相关
    target_tab['loadingcountrycode'] = ['COL'] * imp_df.shape[0] # 启运国国际编码（默认COL）
    target_tab['loadingcountry'] = ['COLOMBIA'] * imp_df.shape[0] # 启运国英文名称（默认COLOMBIA）
    # 运输相关
    target_tab['transportterm'] = imp_df['TRANS_TYPE'] # 运输方式（需映射成统一枚举值）
    # target_tab['tradeterm'] = imp_df['INCOTERMS'] # 成交方式（需映射成统一枚举值，已注释）
    # target_tab['paymentterm'] = imp_df['aaaaa'] # 付款方式（暂未获取到对应字段）
    # 承运人及集装箱相关
    # target_tab['carrier'] = imp_df['aaaaa'] # 承运人名称（暂未获取到对应字段）
    # target_tab['containerno'] = imp_df['aaaaa'] # 集装箱箱号（暂未获取到对应字段）
    # target_tab['vesselname'] = imp_df['aaaaa'] # 船名（暂未获取到对应字段）
    # 品牌
    # target_tab['brand'] = imp_df['BRAND'] # 品牌（需映射成统一枚举值，已注释）
    # 版本
    target_tab['version'] = imp_df['version'] # 版本
    # 国家（模板存在，当前缺失）
    target_tab['country'] = imp_df['src_country'] # 国家（暂未获取到对应字段）
    # 编码ID
    target_tab['IMPORTER_ID'] = imp_df['IMPORTER_ID'] # 渠道采购商编码
    # target_tab['SUPPLIER_ID'] = imp_df['aaaaa'] # 渠道供应商编码（暂未获取到对应字段）
    target_tab['cif_currency'] = 'USD'                         # cif货币类型
    target_tab['fob_currency'] = 'USD'                         # fob货币类型
    
    end = time.time()
    logger.info(f'Import data mapping and cleaning takes {round((end - start) / 60, 2)} minutes')
    
    return target_tab.loc[:,config.target_cols]

def COL_get_target_export(exp_path, src_cols):
    """
    哥伦比亚 出口
    10	拉丁美洲	COLOMBIA	哥伦比亚	COL
    """
    start = time.time()
    
    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    exp_df = pd.read_csv(exp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {exp_df.columns.values}')
    
    target_tab = pd.DataFrame(columns=config.target_cols)
    
    target_tab['channelno'] = ['zdzj'] * exp_df.shape[0] # 渠道缩写
    # 为每条记录生成独立的UUID并去除横线
    target_tab['dataid']             = exp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = exp_df['iesign']                    # 进出口标志
    target_tab['datatype'] = ['D'] * exp_df.shape[0] # 提单关单标志
    target_tab['writeoffflag'] = ['o'] * exp_df.shape[0] # 冲销标志
    # target_tab['writeoffdataid'] = exp_df['aaaaa'] # 冲销记录主键（暂未获取到对应字段）
    target_tab['outputdate'] = [f'{int(x[0]):04d}-{int(x[1]):02d}-{int(x[2]):02d}' for x in
                                exp_df.loc[:, ['YEAR', 'MONTH', 'DAY']].values] # 日期
    # 需要转写为标准英文国名
    # 补充原产国相关字段（模板中存在，当前代码缺失）
    target_tab['origincountrycode']   = ['COL'] * exp_df.shape[0]           # 原产国国际编码
    target_tab['origincountry']       = ['COLOMBIA'] * exp_df.shape[0]    # 原产国英文名称
    # 目的国相关字段
    target_tab['countrycodeofdelivery'] = exp_df['DEST_COUNTRY'] # 目的国国际编码（取自DEST_COUNTRY）
    target_tab['countryofdelivery'] = exp_df['DEST_COUNTRY'] # 目的国英文名称（取自DEST_COUNTRY）
    
    # 采购商相关字段（模板中进口存在，出口可能缺失，按模板补充）
    target_tab['importername'] = exp_df['IMPORTER'] # 采购商名称（暂未获取到对应字段）
    # target_tab['importeraddress'] = exp_df['aaaaa'] # 采购商地址（暂未获取到对应字段）
    # target_tab['importercontact'] = exp_df['aaaaa'] # 采购商联系方式（暂未获取到对应字段）
    # 供应商相关字段
    target_tab['suppliername'] = exp_df['EXPORTER'] # 供应商名称
    # target_tab['supplieraddress'] = exp_df['aaaaa'] # 供应商地址（暂未获取到对应字段）
    # target_tab['suppliercontact'] = exp_df['aaaaa'] # 供应商联系方式（暂未获取到对应字段）
    # 商品编码及描述相关
    target_tab['hscode'] = exp_df['HS_CODE'] # hs编码
    # target_tab['hscodedescription'] = exp_df['aaaaa'] # hs编码描述（暂未获取到对应字段）
    # target_tab['commoditydescription'] = [x.replace("\"", " ") if x is not None else x for x in exp_df['PRODUCT_DESC'].values] # 产品描述（已注释，待启用）
    # 价值相关
    target_tab['totalcifvalue'] = exp_df['FOB'] + exp_df['FREIGHT'] # cif总价（FOB+运费）
    target_tab['totalfobvalue'] = exp_df['FOB'] # fob总价
    # 重量相关
    # target_tab['grossweight'] = exp_df['G_WEIGHT'] # 毛重（已注释，待启用）
    target_tab['netweight'] = exp_df['N_WEIGHT'] # 净重
    # 数量相关
    target_tab['quantity'] = exp_df['QUANTITY'] # 数量
    target_tab['quantityunit'] = exp_df['UNIT_OF_QUANTITY'] # 数量单位
    # TEU（模板存在，当前缺失）
    # target_tab['teu'] = exp_df['aaaaa'] # TEU（暂未获取到对应字段）
    # 货代相关
    # target_tab['importer_forwarderagent'] = exp_df['aaaaa'] # 采购商货代公司标签（暂未获取到对应字段）
    # target_tab['supplier_forwarderagent'] = [0] * exp_df.shape[0] # 供应商货代公司标签（根据EXPORTER判断为0）
    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签

    # 异常数据标志
    target_tab['abnormaldata'] = [0] * exp_df.shape[0] # 是否命中异常数据规则（待判定）
    # 港口相关
    target_tab['portofloading'] = exp_df['CUSTOMS'] # 启运港
    # target_tab['portofdestination'] = exp_df['aaaaa'] # 目的港（暂未获取到对应字段）
    # 启运国相关
    target_tab['loadingcountrycode'] = ['COL'] * exp_df.shape[0] # 启运国国际编码（默认COL）
    target_tab['loadingcountry'] = ['COLOMBIA'] * exp_df.shape[0] # 启运国英文名称（默认COLOMBIA）
    # 运输相关
    # target_tab['transportterm'] = exp_df['TRANS_TYPE'] # 运输方式（需映射成统一枚举值，已注释）
    # target_tab['tradeterm'] = exp_df['INCOTERMS'] # 成交方式（需映射成统一枚举值，已注释）
    # target_tab['paymentterm'] = exp_df['aaaaa'] # 付款方式（暂未获取到对应字段）
    # 承运人及集装箱相关
    # target_tab['carrier'] = exp_df['aaaaa'] # 承运人名称（暂未获取到对应字段）
    # target_tab['containerno'] = exp_df['aaaaa'] # 集装箱箱号（暂未获取到对应字段）
    # target_tab['vesselname'] = exp_df['aaaaa'] # 船名（暂未获取到对应字段）
    # 品牌
    # target_tab['brand'] = exp_df['BRAND'] # 品牌（需映射成统一枚举值，已注释）
    # 版本
    target_tab['version'] = exp_df['version'] # 版本
    # 国家（模板存在，当前缺失）
    target_tab['country'] = exp_df['src_country'] # 国家（暂未获取到对应字段）
    # 编码ID
    # target_tab['IMPORTER_ID'] = exp_df['aaaaa'] # 渠道采购商编码（暂未获取到对应字段）
    target_tab['SUPPLIER_ID'] = exp_df['EXPORTER_ID'] # 渠道供应商编码
    target_tab['cif_currency'] = 'USD'                         # cif货币类型
    target_tab['fob_currency'] = 'USD'                         # fob货币类型
    
    end = time.time()
    logger.info(f'Export data mapping and cleaning takes {round((end - start) / 60, 2)} minutes')
    
    return target_tab.loc[:,config.target_cols]


# 11
def CRI_get_target_import(imp_path, src_cols):
    """
    哥斯达黎加 进口
    11	拉丁美洲	COSTA RICA	哥斯达黎加	CRI
    """
    start = time.time()
    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    imp_df = pd.read_csv(imp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {imp_df.columns.values}')

    target_tab = pd.DataFrame(columns=config.target_cols)

    target_tab['channelno']          = ['zdzj'] * imp_df.shape[0]          # 渠道缩写
    target_tab['dataid']             = imp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = imp_df['iesign']                    # 进出口标志
    target_tab['datatype']           = ['D'] * imp_df.shape[0]             # 提单关单标志
    target_tab['writeoffflag']       = ['o'] * imp_df.shape[0]             # 冲销标志
    # target_tab['writeoffdataid']     = imp_df['aaaaa']                     # 冲销记录主键

    target_tab['outputdate'] = [
        f'{int(x[0]):04d}-{int(x[1]):02d}-{int(x[2]):02d}'
        for x in imp_df.loc[:, ['YEAR', 'MONTH', 'DAY']].values
    ]                                                                        # 日期

    target_tab['origincountrycode']   = imp_df['ORIGIN_COUNTRY']            # 原产国国际编码
    target_tab['origincountry']       = imp_df['ORIGIN_COUNTRY']            # 原产国英文名称
    target_tab['countrycodeofdelivery'] = ['CRI'] * imp_df.shape[0] # 目的国国际编码
    target_tab['countryofdelivery'] = ['COSTA RICA'] * imp_df.shape[0] # 目的国英文名称

    target_tab['importername']        = imp_df['IMPORTER']                  # 采购商名称
    # target_tab['importeraddress']     = imp_df['aaaaa']                     # 采购商地址
    # target_tab['importercontact']     = imp_df['aaaaa']                     # 采购商联系方式

    target_tab['suppliername']        = imp_df['EXPORTER']                     # 供应商名称
    # target_tab['supplieraddress']     = imp_df['aaaaa']                     # 供应商地址
    # target_tab['suppliercontact']     = imp_df['aaaaa']                     # 供应商联系方式

    target_tab['hscode']              = imp_df['HS_CODE']                   # hs编码
    # target_tab['hscodedescription']   = imp_df['aaaaa']                     # hs编码描述
    target_tab['commoditydescription'] = [
        str(x).replace("\"", " ") if x is not None else x
        for x in imp_df['PRODUCT_DESC'].values
    ]                                                                        # 产品描述

    target_tab['totalcifvalue']       = imp_df['CIF_IN_USD']                # cif总价
    target_tab['totalfobvalue']       = imp_df['FOB_IN_USD']                # fob总价
    target_tab['grossweight']         = imp_df['G_WEIGHT']                  # 毛重
    target_tab['netweight']           = imp_df['N_WEIGHT']                  # 重量
    target_tab['quantity']            = imp_df['QTY']                       # 数量
    target_tab['quantityunit']        = imp_df['UOM']                       # 数量单位
    # target_tab['teu']                 = imp_df['aaaaa']                     # TEU

    # target_tab['importer_forwarderagent'] = [0] * imp_df.shape[0]           # 采购商货代公司标签
    # target_tab['supplier_forwarderagent'] = imp_df['aaaaa']                # 供应商货代公司标签
    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签

    target_tab['abnormaldata']        = [0] * imp_df.shape[0]              # 是否命中异常数据规则

    # target_tab['portofloading']       = imp_df['aaaaa']                     # 启运港
    # target_tab['portofdestination']   = imp_df['aaaaa']                     # 目的港

    target_tab['loadingcountrycode']  = imp_df['SHIPPING_COUNTRY']          # 启运国国际编码
    target_tab['loadingcountry']      = imp_df['SHIPPING_COUNTRY']          # 启运国英文名称

    target_tab['transportterm']       = imp_df['TRANS_TYPE']                # 运输方式
    # target_tab['tradeterm']           = imp_df['aaaaa']                     # 成交方式
    # target_tab['paymentterm']         = imp_df['aaaaa']                     # 付款方式
    # target_tab['carrier']             = imp_df['aaaaa']                     # 承运人名称
    # target_tab['containerno']         = imp_df['aaaaa']                     # 集装箱箱号
    target_tab['vesselname']          = imp_df['SHIPPING_NUMBER']           # 船名
    target_tab['brand']               = imp_df['BRAND']                     # 品牌
    target_tab['version']             = imp_df['version']                     # 版本
    target_tab['country']             = imp_df['src_country']                     # 国家

    target_tab['IMPORTER_ID']         = imp_df['IMPORTER_ID']               # 渠道采购商编码
    # target_tab['SUPPLIER_ID']         = imp_df['aaaaa']                     # 渠道供应商编码
    target_tab['cif_currency'] = 'USD'                         # cif货币类型
    target_tab['fob_currency'] = 'USD'                         # fob货币类型

    end = time.time()
    logger.info(f'Import data mapping and cleaning takes {round((end-start)/60,2)} minutes')
    return target_tab.loc[:,config.target_cols]

def CRI_get_target_export(exp_path, src_cols):
    """
    哥斯达黎加 出口
    11	拉丁美洲	COSTA RICA	哥斯达黎加	CRI
    """
    start = time.time()
    
    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    exp_df = pd.read_csv(exp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {exp_df.columns.values}')

    target_tab = pd.DataFrame(columns=config.target_cols)

    target_tab['channelno']          = ['zdzj'] * exp_df.shape[0]          # 渠道缩写
    target_tab['dataid']             = exp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = exp_df['iesign']                    # 进出口标志
    target_tab['datatype']           = ['D'] * exp_df.shape[0]             # 提单关单标志
    target_tab['writeoffflag']       = ['o'] * exp_df.shape[0]             # 冲销标志
    # target_tab['writeoffdataid']     = exp_df['aaaaa']                     # 冲销记录主键

    target_tab['outputdate'] = [
        f'{int(x[0]):04d}-{int(x[1]):02d}-{int(x[2]):02d}'
        for x in exp_df.loc[:, ['YEAR', 'MONTH', 'DAY']].values
    ]                                                                        # 日期

    target_tab['origincountrycode']   = ['CRI'] * exp_df.shape[0]           # 原产国国际编码
    target_tab['origincountry']       = ['COSTA RICA'] * exp_df.shape[0]    # 原产国英文名称
    target_tab['countrycodeofdelivery'] = exp_df['DEST_COUNTRY']            # 目的国国际编码
    target_tab['countryofdelivery']   = exp_df['DEST_COUNTRY']              # 目的国英文名称

    target_tab['importername']        = exp_df['IMPORTER']                     # 采购商名称
    # target_tab['importeraddress']     = exp_df['aaaaa']                     # 采购商地址
    # target_tab['importercontact']     = exp_df['aaaaa']                     # 采购商联系方式

    target_tab['suppliername']        = exp_df['EXPORTER']                  # 供应商名称
    # target_tab['supplieraddress']     = exp_df['aaaaa']                     # 供应商地址
    # target_tab['suppliercontact']     = exp_df['aaaaa']                     # 供应商联系方式

    target_tab['hscode']              = exp_df['HS_CODE']                   # hs编码
    # target_tab['hscodedescription']   = exp_df['aaaaa']                     # hs编码描述
    target_tab['commoditydescription'] = [
        str(x).replace("\"", " ") if x is not None else x
        for x in exp_df['PRODUCT_DESC'].values
    ]                                                                        # 产品描述

    target_tab['totalcifvalue']       = exp_df['CIF_IN_USD']                # cif总价
    target_tab['totalfobvalue']       = exp_df['FOB_IN_USD']                # fob总价
    target_tab['grossweight']         = exp_df['G_WEIGHT']                  # 毛重
    target_tab['netweight']           = exp_df['N_WEIGHT']                  # 重量
    target_tab['quantity']            = exp_df['QTY']                       # 数量
    target_tab['quantityunit']        = exp_df['UOM']                       # 数量单位
    # target_tab['teu']                 = exp_df['aaaaa']                     # TEU

    # target_tab['importer_forwarderagent'] = exp_df['aaaaa']                 # 采购商货代公司标签
    # target_tab['supplier_forwarderagent'] = [0] * exp_df.shape[0]           # 供应商货代公司标签
    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签

    target_tab['abnormaldata']        = [0] * exp_df.shape[0]              # 是否命中异常数据规则

    # target_tab['portofloading']       = exp_df['aaaaa']                     # 启运港
    # target_tab['portofdestination']   = exp_df['aaaaa']                     # 目的港

    target_tab['loadingcountrycode']  = ['CRI'] * exp_df.shape[0]           # 启运国国际编码
    target_tab['loadingcountry']      = ['COSTA RICA'] * exp_df.shape[0]    # 启运国英文名称

    target_tab['transportterm']       = exp_df['TRANS_TYPE']                # 运输方式
    # target_tab['tradeterm']           = exp_df['aaaaa']                     # 成交方式
    # target_tab['paymentterm']         = exp_df['aaaaa']                     # 付款方式
    # target_tab['carrier']             = exp_df['aaaaa']                     # 承运人名称
    # target_tab['containerno']         = exp_df['aaaaa']                     # 集装箱箱号
    target_tab['vesselname']          = exp_df['SHIPPING_NUMBER']           # 船名
    target_tab['brand']               = exp_df['BRAND']                     # 品牌
    target_tab['version']             = exp_df['version']                     # 版本
    target_tab['country']             = exp_df['src_country']                     # 国家

    # target_tab['IMPORTER_ID']         = exp_df['aaaaa']                     # 渠道采购商编码
    target_tab['SUPPLIER_ID']         = exp_df['EXPORTER_ID']               # 渠道供应商编码
    target_tab['cif_currency'] = 'USD'                         # cif货币类型
    target_tab['fob_currency'] = 'USD'                         # fob货币类型

    end = time.time()
    logger.info(f'Export data mapping and cleaning takes {round((end-start)/60,2)} minutes')
    return target_tab.loc[:,config.target_cols]


# 12
def KAZ_get_target_import(imp_path, src_cols):
    """
    哈萨克斯坦 进口
    12	亚洲	KAZAKHSTAN	哈萨克斯坦	KAZ
    """
    start=time.time()
    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    imp_df = pd.read_csv(imp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {imp_df.columns.values}')
    
    target_tab = pd.DataFrame(columns=config.target_cols)
    
    target_tab['channelno'] = ['zdzj']*imp_df.shape[0]  # 渠道缩写
    target_tab['dataid']             = imp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = imp_df['iesign']                    # 进出口标志
    target_tab['writeoffflag'] = ['o']*imp_df.shape[0]  # 冲销标志
    target_tab['datatype'] = ['D'] * imp_df.shape[0]  # 提单关单标志
    
    target_tab['outputdate'] = pd.to_datetime(imp_df['REG_DATE'], format='mixed').dt.strftime('%Y-%m-%d').values  # 日期
    target_tab['origincountrycode'] = imp_df['ORIGIN_COUNTRY_CODE']  # 原产国国际编码
    target_tab['origincountry'] = imp_df['ORIGIN_COUNTRY_NAME']  # 原产国英文名称
    target_tab['countrycodeofdelivery'] = ['KAZ'] * imp_df.shape[0] # 目的国国际编码
    target_tab['countryofdelivery'] = ['KAZAKHSTAN'] * imp_df.shape[0] # 目的国英文名称
    
    target_tab['importername'] = imp_df['CONSIGNEE_NAME']  # 采购商名称
    target_tab['importeraddress'] = imp_df['CONSIGNEE_ADDRESS']  # 采购商地址
    #target_tab['importercontact'] = ['']*imp_df.shape[0]  # 采购商联系方式
    
    target_tab['suppliername'] = imp_df['SHIPPER_NAME']  # 供应商名称
    #target_tab['supplieraddress'] = ['']*imp_df.shape[0]  # 供应商地址
    #target_tab['suppliercontact'] = ['']*imp_df.shape[0]  # 供应商联系方式
    
    target_tab['hscode'] = imp_df['HS_CODE']  # hs编码
    #target_tab['hscodedescription'] = ['']*imp_df.shape[0]  # hs编码描述
    target_tab['commoditydescription'] = [str(x).replace("\"", " ") if x is not None else x for x in imp_df['PRODUCT_DESC_1'].values]  # 产品描述
    target_tab['totalcifvalue'] = imp_df['CUSTOMS_VALUE_USD']  # cif总价
    #target_tab['totalfobvalue'] = [0]*imp_df.shape[0]  # fob总价
    
    target_tab['grossweight'] = imp_df['G_WEIGHT']  # 毛重
    target_tab['netweight'] = imp_df['N_WEIGHT']  # 重量
    target_tab['quantity'] = imp_df['QUANTITY']  # 数量
    target_tab['quantityunit'] = imp_df['UNIT_OF_QUANTITY']  # 数量单位
    #target_tab['teu'] = [0]*imp_df.shape[0]  # TEU
    
    # target_tab['importer_forwarderagent'] = [0] * imp_df.shape[0]  # 采购商货代公司标签
    #target_tab['supplier_forwarderagent'] = [0] * imp_df.shape[0]  # 供应商货代公司标签
    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签

    target_tab['abnormaldata'] = [0] * imp_df.shape[0]  # 是否命中异常数据规则
    
    target_tab['portofloading'] = imp_df['PLACE']  # 启运港
    target_tab['portofdestination'] = imp_df['PLACE']  # 目的港
    # target_tab['loadingcountrycode'] = imp_df['FROM_COUNTRY_CODE']  # 启运国国际编码
    target_tab['loadingcountry'] = imp_df['FROM_COUNTRY_NAME']  # 启运国英文名称
    
    #target_tab['transportterm'] = ['']*imp_df.shape[0]  # 运输方式
    target_tab['tradeterm'] = imp_df['INCOTERMS']  # 成交方式
    #target_tab['paymentterm'] = ['']*imp_df.shape[0]  # 付款方式
    
    target_tab['carrier'] = imp_df['MANUFACTURER']  # 承运人名称
    #target_tab['containerno'] = ['']*imp_df.shape[0]  # 集装箱箱号
    #target_tab['vesselname'] = ['']*imp_df.shape[0]  # 船名
    
    target_tab['brand'] = imp_df['BRAND']  # 品牌
    target_tab['version'] = imp_df['version']  # 版本
    target_tab['country'] = imp_df['src_country']  # 国家
    
    target_tab['IMPORTER_ID'] = imp_df['CONSIGNEE_CODE']  # 渠道采购商编码
    #target_tab['SUPPLIER_ID'] = ['']*imp_df.shape[0]  # 渠道供应商编码
    target_tab['cif_currency'] = 'USD'                         # cif货币类型
    # target_tab['fob_currency'] = 'USD'                         # fob货币类型
    end=time.time()
    logger.info(f'Import data mapping and cleaning takes {round((end-start)/60,2)} minutes')
    
    return target_tab.loc[:,config.target_cols]

def KAZ_get_target_export(exp_path, src_cols):
    """
    哈萨克斯坦 出口
    12	亚洲	KAZAKHSTAN	哈萨克斯坦	KAZ
    """
    start=time.time()
    
    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    exp_df = pd.read_csv(exp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {exp_df.columns.values}')
    
    target_tab = pd.DataFrame(columns=config.target_cols)
    
    target_tab['channelno'] = ['zdzj']*exp_df.shape[0]  # 渠道缩写
    target_tab['dataid']             = exp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = exp_df['iesign']                    # 进出口标志
    target_tab['writeoffflag'] = ['o']*exp_df.shape[0]  # 冲销标志
    target_tab['datatype'] = ['D'] * exp_df.shape[0]  # 提单关单标志
    
    target_tab['outputdate'] = pd.to_datetime(exp_df['REG_DATE'], format='mixed').dt.strftime('%Y-%m-%d').values  # 日期
    target_tab['origincountrycode'] = ['KAZ'] * exp_df.shape[0]  # 原产国国际编码
    target_tab['origincountry'] = ['KAZAKHSTAN'] * exp_df.shape[0]  # 原产国英文名称
    # target_tab['countrycodeofdelivery'] = exp_df['TO_COUNTRY_CODE']  # 目的国国际编码
    target_tab['countryofdelivery'] = exp_df['TO_COUNTRY_NAME']  # 目的国英文名称
    
    target_tab['importername'] = exp_df['CONSIGNEE_NAME']  # 采购商名称
    #target_tab['importeraddress'] = ['']*exp_df.shape[0]  # 采购商地址
    #target_tab['importercontact'] = ['']*exp_df.shape[0]  # 采购商联系方式
    
    target_tab['suppliername'] = exp_df['SHIPPER_NAME']  # 供应商名称
    target_tab['supplieraddress'] = exp_df['SHIPPER_ADDRESS']  # 供应商地址
    #target_tab['suppliercontact'] = ['']*exp_df.shape[0]  # 供应商联系方式
    
    target_tab['hscode'] = exp_df['HS_CODE']  # hs编码
    #target_tab['hscodedescription'] = ['']*exp_df.shape[0]  # hs编码描述
    target_tab['commoditydescription'] = [str(x).replace("\"", " ") if x is not None else x for x in exp_df['PRODUCT_DESC_1'].values]   # 产品描述
    target_tab['totalcifvalue'] = exp_df['CUSTOMS_VALUE_USD']  # cif总价
    # target_tab['totalfobvalue'] = exp_df['CUSTOMS_VALUE_USD']  # fob总价
    
    target_tab['grossweight'] = exp_df['G_WEIGHT']  # 毛重
    target_tab['netweight'] = exp_df['N_WEIGHT']  # 重量
    target_tab['quantity'] = exp_df['QUANTITY']  # 数量
    target_tab['quantityunit'] = exp_df['UNIT_OF_QUANTITY']  # 数量单位
    #target_tab['teu'] = [0]*exp_df.shape[0]  # TEU
    
    #target_tab['importer_forwarderagent'] = ['']*exp_df.shape[0]  # 采购商货代公司标签
    # target_tab['supplier_forwarderagent'] = [0] * exp_df.shape[0]  # 供应商货代公司标签
    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签
    target_tab['abnormaldata'] = [0] * exp_df.shape[0]  # 是否命中异常数据规则
    
    target_tab['portofloading'] = exp_df['PLACE']  # 启运港
    target_tab['portofdestination'] = exp_df['PLACE']  # 目的港
    # target_tab['loadingcountrycode'] = exp_df['FROM_COUNTRY_CODE']  # 启运国国际编码
    target_tab['loadingcountry'] = exp_df['FROM_COUNTRY_NAME']  # 启运国英文名称
    
    #target_tab['transportterm'] = ['']*exp_df.shape[0]  # 运输方式
    target_tab['tradeterm'] = exp_df['INCOTERMS']  # 成交方式
    #target_tab['paymentterm'] = ['']*exp_df.shape[0]  # 付款方式
    
    target_tab['carrier'] = exp_df['MANUFACTURER']  # 承运人名称
    #target_tab['containerno'] = ['']*exp_df.shape[0]  # 集装箱箱号
    #target_tab['vesselname'] = ['']*exp_df.shape[0]  # 船名
    
    target_tab['brand'] = exp_df['BRAND']  # 品牌
    target_tab['version'] = exp_df['version']  # 版本
    target_tab['country'] = exp_df['src_country']  # 国家
    
    #target_tab['IMPORTER_ID'] = ['']*exp_df.shape[0]  # 渠道采购商编码
    target_tab['cif_currency'] = 'USD'                         # cif货币类型
    # target_tab['fob_currency'] = 'USD'                         # fob货币类型
    end=time.time()
    logger.info(f'Export data mapping and cleaning takes {round((end-start)/60,2)} minutes')
    
    return target_tab.loc[:,config.target_cols]


# 13
def GHA_get_target_import(imp_path, src_cols):
    """
    加纳 进口
    13  非洲  GHANA   加纳  GHA
    """
    start=time.time()
    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    imp_df = pd.read_csv(imp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {imp_df.columns.values}')

    target_tab = pd.DataFrame(columns=config.target_cols)

    target_tab['channelno'] = ['zdzj']*imp_df.shape[0] # 渠道缩写
    target_tab['dataid']             = imp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = imp_df['iesign']                    # 进出口标志
    target_tab['datatype'] = ['D'] * imp_df.shape[0] # 提单关单标志
    target_tab['writeoffflag'] = ['o']*imp_df.shape[0] # 冲销标志
    # target_tab['writeoffdataid'] = imp_df['aaa'] # 冲销记录主键

    target_tab['outputdate'] = [f'{int(x[0]):04d}-{int(x[1]):02d}-{int(x[2]):02d}' for x in imp_df.loc[:,['YEAR', 'MONTH', 'DAY']].values] # 日期
    # target_tab['origincountrycode'] = imp_df['COUNTRY'] # 原产国国际编码
    # target_tab['origincountry'] = imp_df['COUNTRY'] # 原产国英文名称
    target_tab['countrycodeofdelivery'] = ['GHA'] * imp_df.shape[0] # 目的国国际编码
    target_tab['countryofdelivery'] = ['GHANA'] * imp_df.shape[0] # 目的国英文名称
    target_tab['importername'] = imp_df['IMPORTER_NAME'] # 采购商名称
    target_tab['importeraddress'] = imp_df['IMPORTER_NAME'] # 采购商地址
    target_tab['importercontact'] = imp_df['IMPORTER_NAME'] # 采购商联系方式
    target_tab['suppliername'] = imp_df['EXPORTER_NAME'] # 供应商名称
    # target_tab['supplieraddress'] = imp_df['aaaaa'] # 供应商地址
    # target_tab['suppliercontact'] = imp_df['aaaaa'] # 供应商联系方式
    target_tab['hscode'] = imp_df['HS_CODE'] # hs编码
    # target_tab['hscodedescription'] = imp_df['aaaaa'] # hs编码描述
    target_tab['commoditydescription'] = [str(x).replace("\"", " ") if x is not None else x for x in imp_df['PRODUCT_DESC'].values] # 产品描述
    
    # target_tab['totalcifvalue'] = imp_df['aaaaa'] # cif总价
    target_tab['totalfobvalue'] = imp_df['ITEM_FOB_IN_GHC'] # fob总价
    target_tab['grossweight'] = imp_df['ITEM_G_WEIGHT_IN_KG'] # 毛重
    target_tab['netweight'] = imp_df['ITEM_N_WEIGHT_IN_KG'] # 重量
    target_tab['quantity'] = imp_df['ITEM_PACKAGES'] # 数量
    target_tab['quantityunit'] = imp_df['ITEM_TYPE_OF_PACKAGE'] # 数量单位
    # target_tab['teu'] = imp_df['aaaaa'] # TEU
    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签

    # target_tab['abnormaldata'] = imp_df['aaaaa'] # 是否命中异常数据规则
    # target_tab['portofloading'] = imp_df['aaaaa'] # 启运港
    # target_tab['portofdestination'] = imp_df['aaaaa'] # 目的港
    # target_tab['loadingcountrycode'] = imp_df['aaaaa'] # 启运国国际编码
    # target_tab['loadingcountry'] = imp_df['aaaaa'] # 启运国英文名称
    # target_tab['transportterm'] = imp_df['aaaaa'] # 运输方式
    # target_tab['tradeterm'] = imp_df['aaaaa'] # 成交方式
    # target_tab['paymentterm'] = imp_df['aaaaa'] # 付款方式
    # target_tab['carrier'] = imp_df['aaaaa'] # 承运人名称
    # target_tab['containerno'] = imp_df['aaaaa'] # 集装箱箱号
    # target_tab['vesselname'] = imp_df['aaaaa'] # 船名
    # target_tab['brand'] = imp_df['aaaaa'] # 品牌
    target_tab['version'] = imp_df['version'] # 版本
    target_tab['country'] = imp_df['src_country'] # 国家
    # target_tab['IMPORTER_ID'] = imp_df['aaaaa'] # 渠道采购商编码
    # target_tab['SUPPLIER_ID'] = imp_df['aaaaa'] # 渠道供应商编码
    # target_tab['cif_currency'] = 'GHA'                         # cif货币类型
    target_tab['fob_currency'] = 'GHA'                         # fob货币类型

    end=time.time()
    logger.info(f'Import data mapping and cleaning takes {round((end-start)/60,2)} minutes')

    return target_tab.loc[:,config.target_cols]

def GHA_get_target_export(exp_path, src_cols):
    """
    加纳 出口
    13  非洲  GHANA   加纳  GHA
    """
    start=time.time()
    
    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    exp_df = pd.read_csv(exp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {exp_df.columns.values}')

    target_tab = pd.DataFrame(columns=config.target_cols)

    target_tab['channelno'] = ['zdzj']*exp_df.shape[0] # 渠道缩写
    target_tab['dataid']             = exp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = exp_df['iesign']                    # 进出口标志
    target_tab['datatype'] = ['D'] * exp_df.shape[0] # 提单关单标志
    target_tab['writeoffflag'] = ['o']*exp_df.shape[0] # 冲销标志
    # target_tab['writeoffdataid'] = exp_df['aaa'] # 冲销记录主键

    target_tab['outputdate'] = pd.to_datetime(exp_df['DECLARATION_DATE'], format='mixed').dt.strftime('%Y-%m-%d').values # 日期
    target_tab['origincountrycode'] = ['GHA'] * exp_df.shape[0]  # 原产国国际编码
    target_tab['origincountry'] = ['GHANA'] * exp_df.shape[0]  # 原产国英文名称
    target_tab['countrycodeofdelivery'] = exp_df['COUNTRY'] # 目的国国际编码
    target_tab['countryofdelivery'] = exp_df['COUNTRY'] # 目的国英文名称
    target_tab['importername'] = exp_df['IMPORTER_NAME'] # 采购商名称
    # target_tab['importeraddress'] = exp_df['aaaaa'] # 采购商地址
    # target_tab['importercontact'] = exp_df['aaaaa'] # 采购商联系方式
    target_tab['suppliername'] = exp_df['EXPORTER_NAME'] # 供应商名称
    target_tab['supplieraddress'] = exp_df['EXPORTER_NAME'] # 供应商地址
    target_tab['suppliercontact'] = exp_df['EXPORTER_NAME'] # 供应商联系方式
    target_tab['hscode'] = exp_df['HS_CODE'] # hs编码
    # target_tab['hscodedescription'] = exp_df['aaaaa'] # hs编码描述
    target_tab['commoditydescription'] = [str(x).replace("\"", " ") if x is not None else x for x in exp_df['PRODUCT_DESC'].values] # 产品描述
    
    target_tab['totalcifvalue'] = exp_df['ITEM_CIF_IN_GHC'] # cif总价
    # target_tab['totalfobvalue'] = exp_df['aaaaa'] # fob总价
    target_tab['grossweight'] = exp_df['ITEM_G_WEIGHT_IN_KG'] # 毛重
    target_tab['netweight'] = exp_df['ITEM_N_WEIGHT_IN_KG'] # 重量
    target_tab['quantity'] = exp_df['ITEM_PACKAGES'] # 数量
    target_tab['quantityunit'] = exp_df['ITEM_TYPE_OF_PACKAGE'] # 数量单位
    # target_tab['teu'] = exp_df['aaaaa'] # TEU
    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签
    # target_tab['abnormaldata'] = exp_df['aaaaa'] # 是否命中异常数据规则
    # target_tab['portofloading'] = exp_df['aaaaa'] # 启运港
    # target_tab['portofdestination'] = exp_df['aaaaa'] # 目的港
    # target_tab['loadingcountrycode'] = exp_df['aaaaa'] # 启运国国际编码
    # target_tab['loadingcountry'] = exp_df['aaaaa'] # 启运国英文名称
    # target_tab['transportterm'] = exp_df['aaaaa'] # 运输方式
    # target_tab['tradeterm'] = exp_df['aaaaa'] # 成交方式
    # target_tab['paymentterm'] = exp_df['aaaaa'] # 付款方式
    # target_tab['carrier'] = exp_df['aaaaa'] # 承运人名称
    # target_tab['containerno'] = exp_df['aaaaa'] # 集装箱箱号
    # target_tab['vesselname'] = exp_df['aaaaa'] # 船名
    # target_tab['brand'] = exp_df['aaaaa'] # 品牌
    target_tab['version'] = exp_df['version'] # 版本
    target_tab['country'] = exp_df['src_country'] # 国家
    # target_tab['IMPORTER_ID'] = exp_df['aaaaa'] # 渠道采购商编码
    # target_tab['SUPPLIER_ID'] = exp_df['aaaaa'] # 渠道供应商编码
    target_tab['cif_currency'] = 'GHA'                         # cif货币类型
    # target_tab['fob_currency'] = 'GHA'                         # fob货币类型

    end=time.time()
    logger.info(f'Export data mapping and cleaning takes {round((end-start)/60,2)} minutes')

    return target_tab.loc[:,config.target_cols]


# 14
def CMR_get_target_import(imp_path, src_cols):
    """
    喀麦隆 进口
    14  非洲  CAMEROON    喀麦隆 CMR
    """
    start=time.time()
    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    imp_df = pd.read_csv(imp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {imp_df.columns.values}')
    
    target_tab = pd.DataFrame(columns=config.target_cols)
    
    target_tab['channelno'] = ['zdzj']*imp_df.shape[0] # 渠道缩写
    target_tab['dataid']             = imp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = imp_df['iesign']                    # 进出口标志
    target_tab['datatype'] = ['D'] * imp_df.shape[0] # 提单关单标志
    target_tab['writeoffflag'] = ['o']*imp_df.shape[0] # 冲销标志
    # target_tab['writeoffdataid'] = imp_df['aaa'] # 冲销记录主键
    target_tab['outputdate'] = pd.to_datetime(imp_df['RELEASE_DATE'], format='mixed').dt.strftime('%Y-%m-%d').values # 日期
    
    target_tab['origincountrycode'] = imp_df['ORIGIN_COUNTRY'] # 原产国国际编码
    target_tab['origincountry'] = imp_df['ORIGIN_COUNTRY'] # 原产国英文名称
    target_tab['countrycodeofdelivery'] = ['CMR'] * imp_df.shape[0] # 目的国国际编码
    target_tab['countryofdelivery'] = ['CAMEROON'] * imp_df.shape[0] # 目的国英文名称
    target_tab['importername'] = imp_df['DOMESTIC_OPERATOR_NAME'] # 采购商名称
    target_tab['importeraddress'] = imp_df['DOMESTIC_OPERATOR_NAME'] # 采购商地址
    target_tab['importercontact'] = imp_df['DOMESTIC_OPERATOR_NAME'] # 采购商联系方式
    target_tab['suppliername'] = imp_df['FOREIGN_PARTNER_NAME'] # 供应商名称
    # target_tab['supplieraddress'] = imp_df['aaaaa'] # 供应商地址
    # target_tab['suppliercontact'] = imp_df['aaaaa'] # 供应商联系方式
    target_tab['hscode'] = imp_df['HS_CODE'] # hs编码
    target_tab['hscodedescription'] = imp_df['HS_CODE_DESC_EN'] # hs编码描述
    target_tab['commoditydescription'] = imp_df['PRODUCT_DESC_FR'] # 产品描述
    target_tab['totalcifvalue'] = imp_df['CARGO_VALUE_XAF'] # cif总价
    # target_tab['totalfobvalue'] = imp_df['CARGO_VALUE_XAF'] # fob总价
    target_tab['grossweight'] = imp_df['G_WEIGHT_IN_KG'] # 毛重
    target_tab['netweight'] = imp_df['N_WEIGHT_IN_KG'] # 重量
    target_tab['quantity'] = imp_df['QTY'] # 数量
    target_tab['quantityunit'] = imp_df['UNIT'] # 数量单位
    # target_tab['teu'] = imp_df['aaaaa'] # TEU
    # target_tab['importer_forwarderagent'] = imp_df['aaaaa'] # 采购商货代公司标签
    # target_tab['supplier_forwarderagent'] = imp_df['aaaaa'] # 供应商货代公司标签
    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签

    target_tab['abnormaldata'] = [1 if x in ['EDD', 'END', 'LOI', 'LOE'] else '0' for x in imp_df['DECLARATION_TYPE_CODE'].values] # 是否命中异常数据规则
    # target_tab['portofloading'] = imp_df['aaaaa'] # 启运港
    # target_tab['portofdestination'] = imp_df['aaaaa'] # 目的港
    # target_tab['loadingcountrycode'] = imp_df['aaaaa'] # 启运国国际编码
    # target_tab['loadingcountry'] = imp_df['aaaaa'] # 启运国英文名称
    target_tab['transportterm'] = imp_df['TRANS_TYPE'] # 运输方式
    # target_tab['tradeterm'] = imp_df['aaaaa'] # 成交方式
    # target_tab['paymentterm'] = imp_df['aaaaa'] # 付款方式
    # target_tab['carrier'] = imp_df['aaaaa'] # 承运人名称
    # target_tab['containerno'] = imp_df['aaaaa'] # 集装箱箱号
    # target_tab['vesselname'] = imp_df['aaaaa'] # 船名
    # target_tab['brand'] = imp_df['aaaaa'] # 品牌
    target_tab['version'] = imp_df['version'] # 版本
    target_tab['country'] = imp_df['src_country'] # 国家
    # target_tab['IMPORTER_ID'] = imp_df['aaaaa'] # 渠道采购商编码
    # target_tab['SUPPLIER_ID'] = imp_df['aaaaa'] # 渠道供应商编码
    target_tab['cif_currency'] = 'CMR'                         # cif货币类型
    # target_tab['fob_currency'] = 'CMR'                         # fob货币类型
    end=time.time()
    logger.info(f'Import data mapping and cleaning takes {round((end-start)/60,2)} minutes')
    
    return target_tab.loc[:,config.target_cols]


# 15
def CIV_get_target_import(imp_path, src_cols):
    """
    科特迪瓦 进口
    15	非洲	COTE D‘IVOIRE	科特迪瓦	CIV
    """
    start = time.time()
    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    imp_df = pd.read_csv(imp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {imp_df.columns.values}')
    
    target_tab = pd.DataFrame(columns=config.target_cols)
    
    # 基础字段
    target_tab['channelno'] = ['zdzj'] * imp_df.shape[0]  # 渠道编号
    target_tab['dataid']             = imp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = imp_df['iesign']                    # 进出口标志
    target_tab['writeoffflag'] = ['o'] * imp_df.shape[0]  # 核销标志
    target_tab['datatype'] = ['D'] * imp_df.shape[0]  # 数据类型
    
    # ----------------------------------------------------
    # 1. 基本信息
    target_tab['outputdate'] = pd.to_datetime(imp_df['REG_DATE'], format='mixed').dt.strftime('%Y-%m-%d').values  # 登记日期
    
    # 2. 国家信息（需要转写为标准英文国名）
    target_tab['origincountrycode'] = imp_df['ORIGIN_COUNTRY_CODE']  # 原产国代码
    target_tab['origincountry'] = imp_df['ORIGIN_COUNTRY_NAME']  # 原产国名称
    target_tab['countrycodeofdelivery'] = ['CIV'] * imp_df.shape[0] # 目的国国际编码
    target_tab['countryofdelivery'] = ['COTE D‘IVOIRE'] * imp_df.shape[0] # 目的国英文名称
    
    # 3. 贸易方信息
    target_tab['importername'] = imp_df['IMPORTER_NAME']  # 进口商名称
    target_tab['suppliername'] = imp_df['EXPORTER']  # 出口商
    
    # 4. 产品信息
    target_tab['hscode'] = imp_df['HS_CODE']  # HS编码
    target_tab['hscodedescription'] = imp_df['HS_CODE_DESC']  # HS编码描述
    
    # 5. 价值重量信息
    target_tab['totalcifvalue'] = imp_df['CIF_VALUE_LOCAL']  # 本地货币CIF值
    target_tab['grossweight'] = imp_df['G_WEIGHT_IN_KG']  # 毛重（千克）
    target_tab['netweight'] = imp_df['N_WEIGHT_IN_KG']  # 净重（千克）
    target_tab['quantity'] = imp_df['QUANTITY']  # 数量
    target_tab['quantityunit'] = imp_df['UNIT_NAME']  # 单位名称
    
    # 6. 运输信息
    # target_tab['importer_forwarderagent'] = [0] * imp_df.shape[0]  # 进口商代理（待判断）
    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签
    target_tab['abnormaldata'] = [0] * imp_df.shape[0]  # 异常数据（待判定）
    target_tab['portofloading'] = imp_df['LOAD_PORT_NAME']  # 装货港名称
    target_tab['loadingcountrycode'] = imp_df['TO_COUNTRY_CODE']  # 运输目的国代码（需转标准英文）
    target_tab['loadingcountry'] = imp_df['TO_COUNTRY_NAME']  # 运输目的国名称（需转标准英文）
    target_tab['transportterm'] = imp_df['TRANS_TYPE']  # 运输方式（需映射成统一枚举值）
    
    # 7. ID字段
    target_tab['IMPORTER_ID'] = imp_df['IMPORER_ID']  # 进口商ID
    target_tab['country'] = imp_df['src_country'] # 国家
    target_tab['version'] = imp_df['version'] # 版本

    target_tab['cif_currency'] = 'CIV'                         # cif货币类型
    # target_tab['fob_currency'] = 'CIV'                         # fob货币类型
    
    end = time.time()
    logger.info(f'Import data mapping and cleaning takes {round((end - start) / 60, 2)} minutes')
    return target_tab.loc[:,config.target_cols]

def CIV_get_target_export(exp_path, src_cols):
    """
    科特迪瓦 出口
    15	非洲	COTE D‘IVOIRE	科特迪瓦	CIV
    """
    start = time.time()
    
    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    exp_df = pd.read_csv(exp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {exp_df.columns.values}')
    
    target_tab = pd.DataFrame(columns=config.target_cols)
    
    # 基础字段
    target_tab['channelno'] = ['zdzj'] * exp_df.shape[0]  # 渠道编号
    target_tab['dataid']             = exp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = exp_df['iesign']                    # 进出口标志
    target_tab['writeoffflag'] = ['o'] * exp_df.shape[0]  # 核销标志
    target_tab['datatype'] = ['D'] * exp_df.shape[0]  # 数据类型
    
    # ----------------------------------------------------
    # 1. 基本信息
    target_tab['outputdate'] = pd.to_datetime(exp_df['REG_DATE'], format='mixed').dt.strftime('%Y-%m-%d').values  # 登记日期
    
    # 2. 国家信息
    target_tab['origincountrycode'] = ['CIV'] * exp_df.shape[0]  # 原产国国际编码
    target_tab['origincountry'] = ['COTE D‘IVOIRE'] * exp_df.shape[0]  # 原产国英文名称
    target_tab['countrycodeofdelivery'] = exp_df['SALES_COUNTRY_CODE']  # 销售目的国代码
    target_tab['countryofdelivery'] = exp_df['SALES_COUNTRY_NAME']  # 销售目的国名称
    
    # 3. 贸易方信息
    target_tab['importername'] = exp_df['IMPORTER_NAME']  # 进口商名称
    target_tab['suppliername'] = exp_df['EXPORTER_NAME']  # 出口商名称
    
    # 4. 产品信息
    target_tab['hscode'] = exp_df['HS_CODE']  # HS编码
    target_tab['hscodedescription'] = exp_df['HS_CODE_DESC']  # HS编码描述
    
    # 5. 价值重量信息
    target_tab['totalcifvalue'] = exp_df['CIF_VALUE_LOCAL']  # 本地货币CIF值
    target_tab['grossweight'] = exp_df['G_WEIGHT_IN_KG']  # 毛重（千克）
    target_tab['netweight'] = exp_df['N_WEIGHT_IN_KG']  # 净重（千克）
    target_tab['quantity'] = exp_df['QUANTITY']  # 数量
    target_tab['quantityunit'] = exp_df['UNIT_NAME']  # 单位名称
    
    # 6. 运输信息
    # target_tab['importer_forwarderagent'] = [0] * exp_df.shape[0]  # 进口商代理（待判断）
    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签
    target_tab['abnormaldata'] = [0] * exp_df.shape[0]  # 异常数据（待判定）
    target_tab['portofdestination'] = exp_df['UNLOAD_PORT_NAME']  # 卸货港名称
    target_tab['loadingcountrycode'] = exp_df['TO_COUNTRY_CODE']  # 运输目的国代码
    target_tab['loadingcountry'] = exp_df['TO_COUNTRY_NAME']  # 运输目的国名称
    target_tab['transportterm'] = exp_df['TRANS_TYPE']  # 运输方式
    
    # 7. ID字段
    target_tab['SUPPLIER_ID'] = exp_df['EXPORTER_ID']  # 出口商ID
    
    target_tab['country'] = exp_df['src_country'] # 国家
    target_tab['cif_currency'] = 'CIV'                         # cif货币类型
    # target_tab['fob_currency'] = 'CIV'                         # fob货币类型
    target_tab['version'] = exp_df['version'] # 版本
    
    end = time.time()
    logger.info(f'Export data mapping and cleaning takes {round((end - start) / 60, 2)} minutes')
    return target_tab.loc[:,config.target_cols]


# 16
def KEN_get_target_import(imp_path, src_cols):
    """
    肯尼亚 进口
    16	非洲	KENYA	肯尼亚	KEN
    """
    start = time.time()
    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    imp_df = pd.read_csv(imp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {imp_df.columns.values}')
    
    target_tab = pd.DataFrame(columns=config.target_cols)
    
    # 基础字段
    target_tab['channelno'] = ['zdzj'] * imp_df.shape[0]  # 渠道编号
    target_tab['dataid']             = imp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = imp_df['iesign']                    # 进出口标志
    target_tab['writeoffflag'] = ['o'] * imp_df.shape[0]  # 核销标志
    target_tab['datatype'] = ['D'] * imp_df.shape[0]  # 数据类型
    
    # ----------------------------------------------------
    # 1. 基本信息
    target_tab['outputdate'] = pd.to_datetime(imp_df['DECLARATION_DATE'], format='mixed').dt.strftime('%Y-%m-%d').values  # 申报日期

    # 2. 国家信息（需要转写为标准英文国名）
    target_tab['origincountrycode'] = imp_df['ORIGIN_COUNTRY_CODE']  # 原产国字母代码
    target_tab['origincountry'] = imp_df['ORIGIN_COUNTRY_NAME']  # 原产国名称
    target_tab['countrycodeofdelivery'] = ['KEN'] * imp_df.shape[0] # 目的国国际编码
    target_tab['countryofdelivery'] = ['KENYA'] * imp_df.shape[0] # 目的国英文名称
    
    # 3. 进口商信息
    target_tab['importername'] = imp_df['IMPORTER_NAME']  # 进口商名称
    target_tab['importeraddress'] = imp_df['IMPORTER_ADDRESS']  # 进口商地址
    
    # 4. 出口商信息
    target_tab['suppliername'] = imp_df['EXPORTER_NAME']  # 出口商名称
    target_tab['supplieraddress'] = imp_df['EXPORTER_ADDRESS']  # 出口商地址
    
    # 5. 产品信息
    target_tab['hscode'] = imp_df['HS_CODE']  # HS编码
    target_tab['hscodedescription'] = imp_df['HS_CODE_DESC']  # HS编码描述
    target_tab['commoditydescription'] = [str(x).replace("\"", " ") if x is not None else x for x in imp_df['PRODUCT_DESC'].values]  # 产品描述（处理引号）
    
    # 6. 价值重量信息
    target_tab['totalfobvalue'] = imp_df['FOB_USD']  # FOB总价
    target_tab['quantity'] = imp_df['QTY']  # 数量
    target_tab['quantityunit'] = imp_df['UOM']  # 计量单位
    
    # 7. 运输信息
    # target_tab['importer_forwarderagent'] = [0] * imp_df.shape[0]  # 进口商代理（待判断）
    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签
    target_tab['abnormaldata'] = [0] * imp_df.shape[0]  # 异常数据（待判定）
    # target_tab['portofloading'] = imp_df['PORT']  # 装运港口
    
    target_tab['version'] = imp_df['version'] # 版本
    target_tab['country'] = imp_df['src_country'] # 国家
    # target_tab['cif_currency'] = 'USD'                         # cif货币类型
    target_tab['fob_currency'] = 'USD'                         # fob货币类型
        
    end = time.time()
    logger.info(f'Import data mapping and cleaning takes {round((end - start) / 60, 2)} minutes')
    return target_tab.loc[:,config.target_cols]


# 17
def LSO_get_target_import(imp_path, src_cols):
    """
    莱索托 进口
    17	非洲	LESOTHO	莱索托	LSO
    """
    start = time.time()
    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    imp_df = pd.read_csv(imp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {imp_df.columns.values}')

    target_tab = pd.DataFrame(columns=config.target_cols)

    target_tab['channelno'] = ['zdzj'] * imp_df.shape[0] # 渠道缩写
    target_tab['dataid']             = imp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = imp_df['iesign']                    # 进出口标志
    target_tab['datatype'] = ['D'] * imp_df.shape[0] # 提单关单标志
    target_tab['writeoffflag'] = ['o'] * imp_df.shape[0] # 冲销标志
    # target_tab['writeoffdataid'] = imp_df['aaaaa'] # 冲销记录主键（暂未获取到对应字段）
    target_tab['outputdate'] = [f'{int(x[0]):04d}-{int(x[1]):02d}-{int(x[2]):02d}' for x in
                                imp_df.loc[:, ['YEAR', 'MONTH', 'DAY']].values] # 日期

    # 需要转写为标准英文国名
    target_tab['origincountrycode'] = imp_df['ORIGIN_COUNTRY'] # 原产国国际编码
    target_tab['origincountry'] = imp_df['ORIGIN_COUNTRY'] # 原产国英文名称
    target_tab['countrycodeofdelivery'] = ['LSO'] * imp_df.shape[0] # 目的国国际编码
    target_tab['countryofdelivery'] = ['LESOTHO'] * imp_df.shape[0] # 目的国英文名称
    
    target_tab['importername'] = imp_df['IMPORTER_NAME'] # 采购商名称
    # target_tab['importeraddress'] = imp_df['aaaaa'] # 采购商地址（暂未获取到对应字段）
    # target_tab['importercontact'] = imp_df['aaaaa'] # 采购商联系方式（暂未获取到对应字段）
    target_tab['suppliername'] = imp_df['EXPORTER_NAME'] # 供应商名称（暂未获取到对应字段）
    # target_tab['supplieraddress'] = imp_df['aaaaa'] # 供应商地址（暂未获取到对应字段）
    # target_tab['suppliercontact'] = imp_df['aaaaa'] # 供应商联系方式（暂未获取到对应字段）
    target_tab['hscode'] = imp_df['HS_CODE'] # hs编码
    target_tab['hscodedescription'] = imp_df['HS_CODE_DESC'] # hs编码描述
    target_tab['commoditydescription'] = [str(x).replace("\"", " ") if x is not None else x for x in
                                          imp_df['PRODUCT_DESC'].values] # 产品描述
    
    target_tab['totalcifvalue'] = imp_df['TOTAL_CARGO_VALUE_USD'] # cif总价
    # target_tab['totalfobvalue'] = imp_df['TOTAL_CARGO_VALUE_USD'] # fob总价
    target_tab['grossweight'] = imp_df['G_WEIGHT'] # 毛重
    target_tab['netweight'] = imp_df['N_WEIGHT'] # 净重
    target_tab['quantity'] = imp_df['PACKAGES'] # 数量
    target_tab['quantityunit'] = imp_df['UNIT_OF_MEASURE'] # 数量单位
    # target_tab['teu'] = imp_df['aaaaa'] # TEU（暂未获取到对应字段）
    # target_tab['importer_forwarderagent'] = [0] * imp_df.shape[0] # 采购商货代公司标签（根据IMPORTER判断为0）
    # target_tab['supplier_forwarderagent'] = imp_df['aaaaa'] # 供应商货代公司标签（暂未获取到对应字段）
    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签
    
    # 待判定
    target_tab['abnormaldata'] = [0] * imp_df.shape[0] # 是否命中异常数据规则

    target_tab['portofloading'] = imp_df['EXIT_PORT'] # 启运港
    target_tab['portofdestination'] = imp_df['ENTRY_PORT'] # 目的港
    # 国家需转换为标准英文国名
    target_tab['loadingcountrycode'] = imp_df['ORIGIN_COUNTRY'] # 启运国国际编码
    target_tab['loadingcountry'] = imp_df['ORIGIN_COUNTRY'] # 启运国英文名称

    # 需映射成统一枚举值
    target_tab['transportterm'] = imp_df['TRANS_TYPE'] # 运输方式
    # 需映射成统一枚举值
    # target_tab['tradeterm'] = imp_df['INCOTERMS'] # 成交方式
    # target_tab['brand'] = imp_df['BRAND'] # 品牌
    # target_tab['paymentterm'] = imp_df['aaaaa'] # 付款方式（暂未获取到对应字段）
    # target_tab['carrier'] = imp_df['aaaaa'] # 承运人名称（暂未获取到对应字段）
    # target_tab['containerno'] = imp_df['aaaaa'] # 集装箱箱号（暂未获取到对应字段）
    # target_tab['vesselname'] = imp_df['aaaaa'] # 船名（暂未获取到对应字段）
    
    target_tab['version'] = imp_df['version'] # 版本
    target_tab['country'] = imp_df['src_country'] # 国家（暂未获取到对应字段）
    target_tab['IMPORTER_ID'] = imp_df['IMPORTER_ID'] # 渠道采购商编码
    # target_tab['SUPPLIER_ID'] = imp_df['aaaaa'] # 渠道供应商编码（暂未获取到对应字段）
    target_tab['cif_currency'] = 'USD'                         # cif货币类型
    # target_tab['fob_currency'] = 'USD'                         # fob货币类型

    end = time.time()
    logger.info(f'Import data mapping and cleaning takes {round((end - start) / 60, 2)} minutes')

    return target_tab.loc[:,config.target_cols]

def LSO_get_target_export(exp_path, src_cols):
    """
    莱索托 出口
    17	非洲	LESOTHO	莱索托	LSO
    """
    start = time.time()
    
    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    exp_df = pd.read_csv(exp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {exp_df.columns.values}')

    target_tab = pd.DataFrame(columns=config.target_cols)

    target_tab['channelno'] = ['zdzj'] * exp_df.shape[0] # 渠道缩写
    target_tab['dataid']             = exp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = exp_df['iesign']                    # 进出口标志
    target_tab['datatype'] = ['D'] * exp_df.shape[0] # 提单关单标志
    target_tab['writeoffflag'] = ['o'] * exp_df.shape[0] # 冲销标志
    # target_tab['writeoffdataid'] = exp_df['aaaaa'] # 冲销记录主键（暂未获取到对应字段）
    target_tab['outputdate'] = [f'{int(x[0]):04d}-{int(x[1]):02d}-{int(x[2]):02d}' for x in
                                exp_df.loc[:, ['YEAR', 'MONTH', 'DAY']].values] # 日期
    # 原产来源国需要再确认
    target_tab['origincountrycode'] = ['LSO'] * exp_df.shape[0]  # 原产国国际编码
    target_tab['origincountry'] = ['LESOTHO'] * exp_df.shape[0]  # 原产国英文名称
    # 需要转写为标准英文国名
    target_tab['countrycodeofdelivery'] = exp_df['DEST_COUNTRY'] # 目的国国际编码
    target_tab['countryofdelivery'] = exp_df['DEST_COUNTRY'] # 目的国英文名称

    target_tab['importername'] = exp_df['IMPORTER_NAME'] # 采购商名称（暂未获取到对应字段）
    # target_tab['importeraddress'] = exp_df['aaaaa'] # 采购商地址（暂未获取到对应字段）
    # target_tab['importercontact'] = exp_df['aaaaa'] # 采购商联系方式（暂未获取到对应字段）
    target_tab['suppliername'] = exp_df['EXPORTER_NAME'] # 供应商名称
    # target_tab['supplieraddress'] = exp_df['aaaaa'] # 供应商地址（暂未获取到对应字段）
    # target_tab['suppliercontact'] = exp_df['aaaaa'] # 供应商联系方式（暂未获取到对应字段）
    target_tab['hscode'] = exp_df['HS_CODE'] # hs编码
    # target_tab['hscodedescription'] = exp_df['aaaaa'] # hs编码描述（暂未获取到对应字段）
    target_tab['commoditydescription'] = [str(x).replace("\"", " ") if x is not None else x for x in
                                          exp_df['PRODUCT_DESC'].values] # 产品描述

    target_tab['totalcifvalue'] = exp_df['CUSTOMS_VALUE_USD'] # cif总价
    target_tab['totalfobvalue'] = exp_df['CUSTOMS_VALUE_USD'] # fob总价
    target_tab['grossweight'] = exp_df['G_WEIGHT'] # 毛重
    target_tab['netweight'] = exp_df['N_WEIGHT'] # 净重
    target_tab['quantity'] = exp_df['PACKAGES'] # 数量
    # target_tab['teu'] = exp_df['aaaaa'] # TEU（暂未获取到对应字段）
    # target_tab['quantityunit'] = exp_df['UNIT_OF_MEASURE'] # 数量单位
    # target_tab['importer_forwarderagent'] = exp_df['aaaaa'] # 采购商货代公司标签（暂未获取到对应字段）
    # target_tab['supplier_forwarderagent'] = [0] * exp_df.shape[0] # 供应商货代公司标签（根据EXPORTER判断为0）
    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签

    # 待判定
    target_tab['abnormaldata'] = [0] * exp_df.shape[0] # 是否命中异常数据规则

    # target_tab['portofloading'] = exp_df['CUSTOMS'] # 启运港（暂未获取到对应字段）
    # target_tab['portofdestination'] = exp_df['aaaaa'] # 目的港（暂未获取到对应字段）
    # 国家需转换为标准英文国名
    target_tab['loadingcountrycode'] = ['LSO'] * exp_df.shape[0] # 启运国国际编码（默认LSO）
    target_tab['loadingcountry'] = ['LESOTHO'] * exp_df.shape[0] # 启运国英文名称（默认LESOTHO）

    # 需映射成统一枚举值
    # target_tab['transportterm'] = exp_df['TRANS_TYPE'] # 运输方式（已注释，待映射）
    # 需映射成统一枚举值
    # target_tab['tradeterm'] = exp_df['INCOTERMS'] # 成交方式
    # target_tab['brand'] = exp_df['BRAND'] # 品牌
    # target_tab['paymentterm'] = exp_df['aaaaa'] # 付款方式（暂未获取到对应字段）
    # target_tab['carrier'] = exp_df['aaaaa'] # 承运人名称（暂未获取到对应字段）
    # target_tab['containerno'] = exp_df['aaaaa'] # 集装箱箱号（暂未获取到对应字段）
    # target_tab['vesselname'] = exp_df['aaaaa'] # 船名（暂未获取到对应字段）

    target_tab['version'] = exp_df['version'] # 版本
    target_tab['country'] = exp_df['src_country'] # 国家（暂未获取到对应字段）
    # target_tab['IMPORTER_ID'] = exp_df['aaaaa'] # 渠道采购商编码（暂未获取到对应字段）
    # target_tab['SUPPLIER_ID'] = exp_df['EXPORT_ID'] # 渠道供应商编码
    target_tab['cif_currency'] = 'USD'                         # cif货币类型
    target_tab['fob_currency'] = 'USD'                         # fob货币类型

    end = time.time()
    logger.info(f'Export data mapping and cleaning takes {round((end - start) / 60, 2)} minutes')

    return target_tab.loc[:,config.target_cols]


# 18
def MWI_get_target_import(imp_path, src_cols):
    """
    马拉维 进口
    18	非洲	MALAWI	马拉维	MWI
    """
    start=time.time()
    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    imp_df = pd.read_csv(imp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {imp_df.columns.values}')

    target_tab = pd.DataFrame(columns=config.target_cols)

    target_tab['channelno'] = ['zdzj']*imp_df.shape[0] # 渠道缩写
    target_tab['dataid']             = imp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = imp_df['iesign']                    # 进出口标志
    target_tab['datatype'] = ['D'] * imp_df.shape[0] # 提单关单标志
    target_tab['writeoffflag'] = ['o']*imp_df.shape[0] # 冲销标志
    # target_tab['writeoffdataid'] = imp_df['aaa'] # 冲销记录主键

    target_tab['outputdate'] = pd.to_datetime(imp_df['REG_DATE'], format='mixed').dt.strftime('%Y-%m-%d').values # 日期
    target_tab['origincountrycode'] = imp_df['ORIGIN_COUNTRY'] # 原产国国际编码
    target_tab['origincountry'] = imp_df['ORIGIN_COUNTRY'] # 原产国英文名称
    target_tab['countrycodeofdelivery'] = ['MWI'] * imp_df.shape[0] # 目的国国际编码
    target_tab['countryofdelivery'] = ['MALAWI'] * imp_df.shape[0] # 目的国英文名称
    target_tab['importername'] = imp_df['IMPORTER_NAME'] # 采购商名称
    target_tab['importeraddress'] = imp_df['IMPORTER_ADDRESS_1'] # 采购商地址
    # target_tab['importercontact'] = imp_df['aaaaa'] # 采购商联系方式
    target_tab['suppliername'] = imp_df['EXPORTER_NAME'] # 供应商名称
    # target_tab['supplieraddress'] = imp_df['aaaaa'] # 供应商地址
    # target_tab['suppliercontact'] = imp_df['aaaaa'] # 供应商联系方式
    target_tab['hscode'] = imp_df['HS_CODE'] # hs编码
    # target_tab['hscodedescription'] = imp_df['aaaaa'] # hs编码描述
    target_tab['commoditydescription'] = [str(x).replace("\"", " ") if x is not None else x for x in imp_df['PRODUCT_DESC'].values] # 产品描述
    target_tab['totalcifvalue'] = imp_df['VDP_AMOUNT_USD'] # cif总价
    target_tab['totalfobvalue'] = imp_df['FOB_IN_FOREIGN_CURRENCY'] # fob总价
    target_tab['grossweight'] = imp_df['G_WEIGHT_KG'] # 毛重
    target_tab['netweight'] = imp_df['N_WEIGHT_KG'] # 重量
    target_tab['quantity'] = imp_df['QTY'] # 数量
    target_tab['quantityunit'] = imp_df['UOM'] # 数量单位
    # target_tab['teu'] = imp_df['aaaaa'] # TEU
    # target_tab['importer_forwarderagent'] = imp_df['aaaaa'] # 采购商货代公司标签
    # target_tab['supplier_forwarderagent'] = imp_df['aaaaa'] # 供应商货代公司标签
    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签
    # target_tab['abnormaldata'] = imp_df['aaaaa'] # 是否命中异常数据规则
    # target_tab['portofloading'] = imp_df['aaaaa'] # 启运港
    # target_tab['portofdestination'] = imp_df['aaaaa'] # 目的港
    # target_tab['loadingcountrycode'] = imp_df['aaaaa'] # 启运国国际编码
    # target_tab['loadingcountry'] = imp_df['aaaaa'] # 启运国英文名称
    target_tab['transportterm'] = imp_df['TRANS_TYPE_CODE'] # 运输方式
    # target_tab['tradeterm'] = imp_df['aaaaa'] # 成交方式
    # target_tab['paymentterm'] = imp_df['aaaaa'] # 付款方式
    # target_tab['carrier'] = imp_df['aaaaa'] # 承运人名称
    # target_tab['containerno'] = imp_df['aaaaa'] # 集装箱箱号
    # target_tab['vesselname'] = imp_df['aaaaa'] # 船名
    # target_tab['brand'] = imp_df['aaaaa'] # 品牌
    target_tab['version'] = imp_df['version'] # 版本
    target_tab['country'] = imp_df['src_country'] # 国家
    # target_tab['IMPORTER_ID'] = imp_df['aaaaa'] # 渠道采购商编码
    # target_tab['SUPPLIER_ID'] = imp_df['aaaaa'] # 渠道供应商编码
    target_tab['cif_currency'] = 'USD'                         # cif货币类型
    target_tab['fob_currency'] = imp_df['FOREIGN_CURRENCY']                        # fob货币类型

    end=time.time()
    logger.info(f'Import data mapping and cleaning takes {round((end-start)/60,2)} minutes')

    return target_tab.loc[:,config.target_cols]

def MWI_get_target_export(exp_path, src_cols):
    """
    马拉维 出口
    18	非洲	MALAWI	马拉维	MWI
    """
    start=time.time()
    
    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    exp_df = pd.read_csv(exp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {exp_df.columns.values}')

    target_tab = pd.DataFrame(columns=config.target_cols)

    target_tab['channelno'] = ['zdzj']*exp_df.shape[0] # 渠道缩写
    target_tab['dataid']             = exp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = exp_df['iesign']                    # 进出口标志
    target_tab['datatype'] = ['D'] * exp_df.shape[0] # 提单关单标志
    target_tab['writeoffflag'] = ['o']*exp_df.shape[0] # 冲销标志
    # target_tab['writeoffdataid'] = exp_df['aaa'] # 冲销记录主键

    target_tab['outputdate'] = pd.to_datetime(exp_df['REG_DATE'], format='mixed').dt.strftime('%Y-%m-%d').values # 日期
    target_tab['origincountrycode'] = ['MWI'] * exp_df.shape[0]  # 原产国国际编码
    target_tab['origincountry'] = ['MALAWI'] * exp_df.shape[0]  # 原产国英文名称
    target_tab['countrycodeofdelivery'] = exp_df['DEST_COUNTRY'] # 目的国国际编码
    target_tab['countryofdelivery'] = exp_df['DEST_COUNTRY'] # 目的国英文名称
    target_tab['importername'] = exp_df['IMPORTER_NAME'] # 采购商名称
    # target_tab['importeraddress'] = exp_df['aaaaa'] # 采购商地址
    # target_tab['importercontact'] = exp_df['aaaaa'] # 采购商联系方式
    target_tab['suppliername'] = exp_df['EXPORTER_NAME'] # 供应商名称
    target_tab['supplieraddress'] = exp_df['EXPORTER_ADDRESS_1'] # 供应商地址
    # target_tab['suppliercontact'] = exp_df['aaaaa'] # 供应商联系方式
    target_tab['hscode'] = exp_df['HS_CODE'] # hs编码
    # target_tab['hscodedescription'] = exp_df['aaaaa'] # hs编码描述
    target_tab['commoditydescription'] = [str(x).replace("\"", " ") if x is not None else x for x in exp_df['PRODUCT_DESC'].values]    # 产品描述
    # target_tab['totalcifvalue'] = exp_df['aaaaa'] # cif总价
    target_tab['totalfobvalue'] = exp_df['FOB_IN_USD'] # fob总价
    target_tab['grossweight'] = exp_df['G_WEIGHT_KG'] # 毛重
    target_tab['netweight'] = exp_df['N_WEIGHT_KG'] # 重量
    target_tab['quantity'] = exp_df['QTY'] # 数量
    target_tab['quantityunit'] = exp_df['UOM'] # 数量单位
    # target_tab['teu'] = exp_df['aaaaa'] # TEU
    # target_tab['importer_forwarderagent'] = exp_df['aaaaa'] # 采购商货代公司标签
    # target_tab['supplier_forwarderagent'] = exp_df['aaaaa'] # 供应商货代公司标签
    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签
    # target_tab['abnormaldata'] = exp_df['aaaaa'] # 是否命中异常数据规则
    # target_tab['portofloading'] = exp_df['aaaaa'] # 启运港
    # target_tab['portofdestination'] = exp_df['aaaaa'] # 目的港
    # target_tab['loadingcountrycode'] = exp_df['aaaaa'] # 启运国国际编码
    # target_tab['loadingcountry'] = exp_df['aaaaa'] # 启运国英文名称
    # target_tab['transportterm'] = exp_df['aaaaa'] # 运输方式
    # target_tab['tradeterm'] = exp_df['aaaaa'] # 成交方式
    # target_tab['paymentterm'] = exp_df['aaaaa'] # 付款方式
    # target_tab['carrier'] = exp_df['aaaaa'] # 承运人名称
    # target_tab['containerno'] = exp_df['aaaaa'] # 集装箱箱号
    # target_tab['vesselname'] = exp_df['aaaaa'] # 船名
    # target_tab['brand'] = exp_df['aaaaa'] # 品牌
    target_tab['version'] = exp_df['version'] # 版本
    target_tab['country'] = exp_df['src_country'] # 国家
    # target_tab['IMPORTER_ID'] = exp_df['aaaaa'] # 渠道采购商编码
    # target_tab['SUPPLIER_ID'] = exp_df['aaaaa'] # 渠道供应商编码
    # target_tab['cif_currency'] = 'USD'                         # cif货币类型
    target_tab['fob_currency'] = 'USD'                        # fob货币类型

    end=time.time()
    logger.info(f'Export data mapping and cleaning takes {round((end-start)/60,2)} minutes')

    return target_tab.loc[:,config.target_cols]


# 19
def USA_get_target_import(imp_path, src_cols):
    """
    美国 进口
    19	北美洲	UNITED STATES OF AMERICA	美国	USA
    """
    start = time.time()
    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    imp_df = pd.read_csv(imp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {imp_df.columns.values}')

    target_tab = pd.DataFrame(columns=config.target_cols)

    target_tab['channelno'] = ['zdzj'] * imp_df.shape[0]  # 渠道缩写
    target_tab['dataid']             = imp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = imp_df['iesign']                    # 进出口标志
    target_tab['writeoffflag'] = ['o'] * imp_df.shape[0]  # 冲销标志
    target_tab['outputdate'] = pd.to_datetime(imp_df['act_arrival_date'], format='mixed').dt.strftime('%Y-%m-%d').values  # 日期
    
    # 需要转写为标准英文国名
    # target_tab['origincountrycode'] = imp_df['COUNTRY']  # 原产国国际编码
    # target_tab['origincountry'] = imp_df['COUNTRY']  # 原产国英文名称
    target_tab['countrycodeofdelivery'] = ['USA'] * imp_df.shape[0] # 目的国国际编码
    target_tab['countryofdelivery'] = ['UNITED STATES OF AMERICA'] * imp_df.shape[0] # 目的国英文名称
    target_tab['importername'] = imp_df['CONSIGNEENAME']  # 采购商名称
    target_tab['importeraddress'] = imp_df['CONSIGNEE_ADDR_1']  # 采购商地址
    # target_tab['CONSIGNEENAME'] = imp_df['IMPORTER_NAME']  # 采购商联系方式
    target_tab['suppliername'] = imp_df['SHIPPERNAME']  # 供应商名称
    target_tab['supplieraddress'] = imp_df['SHIPPER_ADDR_1']  # 供应商地址
    # target_tab['suppliercontact'] = imp_df['SHIPPERNAME']  # 供应商联系方式
    target_tab['hscode'] = imp_df['HSCODE']  # hs编码
    # target_tab['hscodedescription'] = imp_df['aaa']# hs编码描述
    target_tab['commoditydescription'] = [str(x).replace("\"", " ") if x is not None else x for x in
                                          imp_df['PRODUCTS'].values]  # 产品描述
    # target_tab['totalcifvalue'] = imp_df['aaa']# cif总价
    # target_tab['totalfobvalue'] = imp_df['aaaa'] # fob总价
    target_tab['grossweight'] = imp_df['weight']  # 毛重
    # target_tab['netweight'] = imp_df['aaa']# 重量
    target_tab['quantity'] = imp_df['piece_count']  # 数量
    target_tab['quantityunit'] = imp_df['manifest_units']  # 数量单位
    # 需要判断根据imp_df['IMPORTER']判断是否为0/1
    target_tab['importer_forwarderagent'] = [0] * imp_df.shape[0]
    # 待判定
    target_tab['abnormaldata'] = [0] * imp_df.shape[0]

    target_tab['teu'] = imp_df['teu']  # TEU
    # target_tab['importer_forwarderagent']= imp_df['IMPORTER']# 采购商货代公司标签
    # target tab['supplier forwarderagent']= imp df['aaaaa']# 供应商货代公司标签
    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签
    # target_tab['abnormaldata']= imp_df['aaaaa']# 是否命中异常数据规则
    target_tab['portofloading'] = imp_df['STARTPORT']  # 启运港
    target_tab['portofdestination'] = imp_df['ENDPORT']  # 目的港
    # target_tab['loadingcountrycode'] = imp_df['aaa'] # 启运国国际编码
    # target_tab['loadingcountry'] = imp_df['aaa'] # 启运国英文名称
    target_tab['transportterm'] = imp_df['mode_transport']  # 运输方式
    # target tab['tradeterm']= imp df['aaaaa']# 成交方式
    # target_tab['paymentterm']= imp_df['aaaaa']# 付款方式
    # target_tab['carrier']= imp_df['aaaaa']# 承运人名称
    target_tab['containerno'] = imp_df['container_number']  # 集装箱箱号
    target_tab['vesselname'] = imp_df['vessel_name']  # 船名
    # target_tab['brand']= imp_df['aaaaa']# 品牌
    target_tab['version']= imp_df['version']# 版本
    target_tab['country']= imp_df['src_country']# 国家
    # target_tab['IMPORTER_ID'] = imp_df['aaaa']# 渠道采购商编码

    target_tab['datatype'] = ['B'] * imp_df.shape[0]  # 提单关单标志
    # target_tab['cif_currency'] = 'USD'                         # cif货币类型
    # target_tab['fob_currency'] = 'USD'                        # fob货币类型

    end = time.time()
    logger.info(f'Import data mapping and cleaning takes {round((end - start) / 60, 2)} minutes')

    return target_tab.loc[:,config.target_cols]

def USA_get_target_export(exp_path, src_cols):
    """
    美国 出口
    19	北美洲	UNITED STATES OF AMERICA	美国	USA
    """
    start=time.time()
    
    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    exp_df = pd.read_csv(exp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {exp_df.columns.values}')
    
    target_tab = pd.DataFrame(columns=config.target_cols)
    target_tab['channelno'] = ['zdzj'] * exp_df.shape[0] # 渠道缩写
    target_tab['dataid']             = exp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = exp_df['iesign']                    # 进出口标志
    target_tab['datatype']  = ['B'] * exp_df.shape[0] # 提单关单标志
    target_tab['writeoffflag'] = ['o'] * exp_df.shape[0] # 冲销标志
    # target_tab['writeoffdataid'] = exp_df['aaa'] # 冲销记录主键
    target_tab['outputdate'] = pd.to_datetime(exp_df['DEPARTURE_DATE'], format='mixed').dt.strftime('%Y-%m-%d').values  # 日期
    
    target_tab['origincountrycode'] = ['USA'] * exp_df.shape[0]  # 原产国国际编码
    target_tab['origincountry'] = ['UNITED STATES OF AMERICA'] * exp_df.shape[0]  # 原产国英文名称
    target_tab['countrycodeofdelivery'] = exp_df['DESTINY_COUNTRY'] # 目的国国际编码
    target_tab['countryofdelivery']     = exp_df['DESTINY_COUNTRY'] # 目的国英文名称
    # target_tab['importername']   = exp_df['IMPORTER_NAME'] # 采购商名称
    # target_tab['importeraddress']= exp_df['IMPORTER_NAME'] # 采购商地址
    # target_tab['importercontact']= exp_df['IMPORTER_NAME'] # 采购商联系方式
    target_tab['suppliername']      = exp_df['SHIPPER'] # 供应商名称
    target_tab['supplieraddress']   = exp_df['SHIPPER'] # 供应商地址
    target_tab['suppliercontact']   = exp_df['SHIPPER'] # 供应商联系方式
    target_tab['hscode']            = exp_df['HS_CODE'] # hs编码
    # target_tab['hscodedescription'] = exp_df['aaa'] # hs编码描述
    target_tab['commoditydescription'] = [str(x).replace('"', ' ') if pd.notnull(x) else x
                                          for x in exp_df['CARGO_DESCRIPTION']] # 产品描述
    # target_tab['totalcifvalue'] = exp_df['aaa'] # cif总价
    # target_tab['totalfobvalue'] = exp_df['aaaaa'] # fob总价
    target_tab['grossweight']   = exp_df['WEIGHT'] # 毛重
    # target_tab['netweight']     = exp_df['aaa'] # 重量
    target_tab['quantity']      = exp_df['QUANTITY'] # 数量
    target_tab['quantityunit']  = exp_df['UNIT'] # 数量单位
    # target_tab['teu'] = exp_df['aaaaa'] # TEU
    # target_tab['importer_forwarderagent'] = exp_df['aaaaa'] # 采购商货代公司标签
    # target_tab['supplier_forwarderagent'] = [0] * exp_df.shape[0] # 供应商货代公司标签
    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签
    target_tab['abnormaldata']            = [0] * exp_df.shape[0] # 是否命中异常数据规则
    target_tab['portofloading'] = exp_df['DEPARTURE_PORT'] # 启运港
    target_tab['portofdestination'] = exp_df['ARRIVAL_PORT'] # 目的港
    # target_tab['loadingcountrycode'] = exp_df['aaa'] # 启运国国际编码
    # target_tab['loadingcountry']     = exp_df['aaa'] # 启运国英文名称
    # target_tab['transportterm'] = exp_df['TRANS_TYPE'] # 运输方式
    # target_tab['tradeterm'] = exp_df['aaaaa'] # 成交方式
    # target_tab['paymentterm'] = exp_df['aaaaa'] # 付款方式
    # target_tab['carrier'] = exp_df['aaaaa'] # 承运人名称
    # target_tab['containerno'] = exp_df['aaaaa'] # 集装箱箱号
    target_tab['vesselname']    = exp_df['VESSEL'] # 船名
    # target_tab['brand'] = exp_df['aaaaa'] # 品牌
    target_tab['version'] = exp_df['version'] # 版本
    target_tab['country'] = exp_df['src_country'] # 国家
    # target_tab['IMPORTER_ID'] = exp_df['aaaaa'] # 渠道采购商编码
    # target_tab['SUPPLIER_ID'] = exp_df['aaa'] # 渠道供应商编码
    # target_tab['cif_currency'] = 'USD'                         # cif货币类型
    # target_tab['fob_currency'] = 'USD'                        # fob货币类型
    
    end=time.time()
    logger.info(f'Export data mapping and cleaning takes {round((end-start)/60,2)} minutes')
    return target_tab.loc[:,config.target_cols]


# 20
def BGD_get_target_import(imp_path, src_cols):
    """
    孟加拉 进口
    20	亚洲	BANGLADESH	孟加拉	BGD
    """
    start = time.time()
    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    imp_df = pd.read_csv(imp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {imp_df.columns.values}')

    target_tab = pd.DataFrame(columns=config.target_cols)

    target_tab['channelno']          = ['zdzj'] * imp_df.shape[0]          # 渠道缩写
    target_tab['dataid']             = imp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = imp_df['iesign']                    # 进出口标志
    target_tab['datatype']           = ['D'] * imp_df.shape[0]             # 提单关单标志
    target_tab['writeoffflag']       = ['o'] * imp_df.shape[0]             # 冲销标志
    # target_tab['writeoffdataid']     = imp_df['aaaaa']                     # 冲销记录主键

    target_tab['outputdate']         = pd.to_datetime(imp_df['REG_DATE'], format='mixed').dt.strftime('%Y-%m-%d').values                   # 日期
    target_tab['origincountrycode']  = imp_df['ORIGIN_COUNTRY']            # 原产国国际编码
    target_tab['origincountry']      = imp_df['ORIGIN_COUNTRY']            # 原产国英文名称
    target_tab['countrycodeofdelivery'] = ['BGD'] * imp_df.shape[0] # 目的国国际编码
    target_tab['countryofdelivery'] = ['BANGLADESH'] * imp_df.shape[0] # 目的国英文名称
    target_tab['importername']       = imp_df['IMPORTER']                   # 采购商名称
    target_tab['importeraddress']    = imp_df['IMPORTER_ADDRESS']           # 采购商地址
    # target_tab['importercontact']    = imp_df['aaaaa']                     # 采购商联系方式
    target_tab['suppliername']       = imp_df['EXPORTER']                     # 供应商名称
    # target_tab['supplieraddress']    = imp_df['aaaaa']                     # 供应商地址
    # target_tab['suppliercontact']    = imp_df['aaaaa']                     # 供应商联系方式
    target_tab['hscode']             = imp_df['HS_CODE']                    # hs编码
    target_tab['hscodedescription']  = imp_df['HS_CODE_DESC']              # hs编码描述
    target_tab['commoditydescription'] = [
        str(x).replace("\"", " ") if x is not None else x
        for x in imp_df['PRODUCT_DESC'].values
    ]                                                                        # 产品描述
    target_tab['totalcifvalue']      = imp_df['TOTAL_VALUE_INVOICE']       # cif总价
    # target_tab['totalfobvalue']      = imp_df['TOTAL_VALUE_INVOICE']       # fob总价
    # target_tab['grossweight']        = imp_df['aaaaa']                     # 毛重
    target_tab['netweight']          = imp_df['N_WEIGHT_IN_KG']            # 重量
    target_tab['quantity']           = imp_df['QUANTITY']                  # 数量
    target_tab['quantityunit']       = imp_df['UNIT_OF_QUANTITY']          # 数量单位
    # target_tab['teu']                = imp_df['aaaaa']                     # TEU
    # target_tab['importer_forwarderagent'] = [0] * imp_df.shape[0]          # 采购商货代公司标签
    # target_tab['supplier_forwarderagent'] = imp_df['aaaaa']                # 供应商货代公司标签
    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签
    target_tab['abnormaldata']       = [0] * imp_df.shape[0]               # 是否命中异常数据规则
    # target_tab['portofloading']      = imp_df['aaaaa']                    # 启运港
    # target_tab['portofdestination']  = imp_df['aaaaa']                    # 目的港
    target_tab['loadingcountrycode'] = ['BGD'] * imp_df.shape[0]           # 启运国国际编码
    target_tab['loadingcountry']     = ['BANGLADESH'] * imp_df.shape[0]    # 启运国英文名称
    # target_tab['transportterm']      = imp_df['aaaaa']                     # 运输方式（需映射成统一枚举值）
    # target_tab['tradeterm']          = imp_df['aaaaa']                     # 成交方式
    # target_tab['paymentterm']        = imp_df['aaaaa']                     # 付款方式
    # target_tab['carrier']            = imp_df['aaaaa']                     # 承运人名称
    # target_tab['containerno']        = imp_df['aaaaa']                     # 集装箱箱号
    # target_tab['vesselname']         = imp_df['aaaaa']                     # 船名
    # target_tab['brand']              = imp_df['BRAND']                      # 品牌
    target_tab['version']            = imp_df['version']                     # 版本
    target_tab['country']            = imp_df['src_country']                     # 国家
    target_tab['IMPORTER_ID']        = imp_df['IMPORTER']                   # 渠道采购商编码
    # target_tab['SUPPLIER_ID']        = imp_df['aaaaa']                     # 渠道供应商编码
    target_tab['cif_currency'] = 'USD'                         # cif货币类型
    # target_tab['fob_currency'] = 'USD'                        # fob货币类型
    
    end = time.time()
    logger.info(f'Import data mapping and cleaning takes {round((end-start)/60,2)} minutes')
    return target_tab.loc[:,config.target_cols]


# 21
def PER_get_target_import(imp_path, src_cols):
    """秘鲁 进口
    21	拉丁美洲	PERU	秘鲁	PER
    """
    start=time.time()
    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    imp_df = pd.read_csv(imp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {imp_df.columns.values}')
    
    target_tab = pd.DataFrame(columns=config.target_cols)
    
    target_tab['channelno'] = ['zdzj'] * imp_df.shape[0]  # 渠道缩写
    target_tab['dataid']             = imp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = imp_df['iesign']                    # 进出口标志
    target_tab['datatype'] = ['D'] * imp_df.shape[0]  # 提单关单标志
    target_tab['writeoffflag'] = ['o'] * imp_df.shape[0]  # 冲销标志
    # target_tab['writeoffdataid'] = imp_df['writeoffdataid']  # 冲销记录主键
    target_tab['outputdate'] = [f'{int(x[0]):04d}-{int(x[1]):02d}-{int(x[2]):02d}' for x in  imp_df.loc[:,['YEAR', 'MONTH', 'DAY']].values]  # 日期  # 日期  # 日期
    target_tab['origincountrycode'] = imp_df['ORIGIN_COUNTRY']  # 原产国国际编码
    target_tab['origincountry'] = imp_df['ORIGIN_COUNTRY']  # 原产国英文名称
    target_tab['countrycodeofdelivery'] = ['PER'] * imp_df.shape[0] # 目的国国际编码
    target_tab['countryofdelivery'] = ['PERU'] * imp_df.shape[0] # 目的国英文名称
    target_tab['importername'] = imp_df['IMPORTER']  # 采购商名称
    target_tab['importeraddress'] = imp_df['IMPORTER_ADDRESS']  # 采购商地址
    target_tab['importercontact'] = imp_df['IMPORTER_TEL']  # 采购商联系方式
    # target_tab['suppliername'] = imp_df['suppliername']  # 供应商名称
    # target_tab['supplieraddress'] = imp_df['supplieraddress']  # 供应商地址
    # target_tab['suppliercontact'] = imp_df['suppliercontact']  # 供应商联系方式
    target_tab['hscode'] = imp_df['HS_CODE']  # hs编码
    target_tab['hscodedescription'] = imp_df['HS_CODE_DESC']  # hs编码描述
    target_tab['commoditydescription'] = [str(x).replace("\"", " ") if x is not None else x for x in  imp_df['PRODUCT_DESC'].values]  # 产品描述
    target_tab['totalcifvalue'] = imp_df['CIF']  # cif总价
    target_tab['totalfobvalue'] = imp_df['FOB']  # fob总价
    target_tab['grossweight'] = imp_df['G_WEIGHT']  # 毛重
    target_tab['netweight'] = imp_df['N_WEIGHT']  # 重量
    target_tab['quantity'] = imp_df['QUANTITY']  # 数量
    target_tab['quantityunit'] = imp_df['UNIT_OF_QUANTITY']  # 数量单位
    # target_tab['teu'] = imp_df['teu']  # TEU
    # target_tab['importer_forwarderagent'] = [0] * imp_df.shape[0]  # 采购商货代公司标签
    # target_tab['supplier_forwarderagent'] = imp_df['supplier_forwarderagent']  #  供应商货代公司标签
    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签
    target_tab['abnormaldata'] = [0] * imp_df.shape[0]  # 是否命中异常数据规则
    target_tab['portofloading'] = imp_df['ORIGIN_PORT']  # 启运港
    # target_tab['portofdestination'] = imp_df['portofdestination']  # 目的港
    # target_tab['loadingcountrycode'] = imp_df['loadingcountrycode']  # 启运国国际编码
    # target_tab['loadingcountry'] = imp_df['loadingcountry']  # 启运国英文名称
    target_tab['transportterm'] = imp_df['TRANS_TYPE']  # 运输方式
    # target_tab['tradeterm'] = imp_df['INCOTERM']  # 成交方式
    # target_tab['paymentterm'] = imp_df['paymentterm']  # 付款方式
    # target_tab['carrier'] = imp_df['carrier']  # 承运人名称
    # target_tab['containerno'] = imp_df['containerno']  # 集装箱箱号
    # target_tab['vesselname'] = imp_df['vesselname']  # 船名
    # target_tab['brand'] = imp_df['brand']  # 品牌
    target_tab['version'] = imp_df['version']  # 版本
    target_tab['country'] = imp_df['src_country']  # 国家
    target_tab['IMPORTER_ID'] = imp_df['IMPORTER_ID']  # 渠道采购商编码
    # target_tab['SUPPLIER_ID'] = imp_df['SUPPLIER_ID']  # 渠道供应商编码
    target_tab['cif_currency'] = 'USD'                         # cif货币类型
    target_tab['fob_currency'] = 'USD'                        # fob货币类型
    end=time.time()
    logger.info(f'Import data mapping and cleaning takes {round((end-start)/60,2)} minutes')
    
    return target_tab.loc[:,config.target_cols]

def PER_get_target_export(exp_path, src_cols):
    """
    秘鲁 出口
    21	拉丁美洲	PERU	秘鲁	PER
    """
    start=time.time()
    
    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    exp_df = pd.read_csv(exp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {exp_df.columns.values}')
    
    target_tab = pd.DataFrame(columns=config.target_cols)
    
    target_tab['channelno'] = ['zdzj'] * exp_df.shape[0]  # 渠道缩写
    target_tab['dataid']             = exp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = exp_df['iesign']                    # 进出口标志
    target_tab['datatype'] = ['D'] * exp_df.shape[0]  # 提单关单标志
    target_tab['writeoffflag'] = ['o'] * exp_df.shape[0]  # 冲销标志
    # target_tab['writeoffdataid'] = exp_df['writeoffdataid']  # 冲销记录主键
    target_tab['outputdate'] = [f'{int(x[0]):04d}-{int(x[1]):02d}-{int(x[2]):02d}' for x in   exp_df.loc[:, ['YEAR', 'MONTH', 'DAY']].values]  # 日期
    target_tab['origincountrycode'] = ['PER'] * exp_df.shape[0]  # 原产国国际编码
    target_tab['origincountry'] = ['PERU'] * exp_df.shape[0]  # 原产国英文名称
    target_tab['countrycodeofdelivery'] = exp_df['DEST_COUNTRY']  # 目的国国际编码
    target_tab['countryofdelivery'] = exp_df['DEST_COUNTRY']  # 目的国英文名称
    # target_tab['importername'] = exp_df['importername']  # 采购商名称
    # target_tab['importeraddress'] = exp_df['importeraddress']  # 采购商地址
    # target_tab['importercontact'] = exp_df['importercontact']  # 采购商联系方式
    target_tab['suppliername'] = exp_df['EXPORTER']  # 供应商名称
    target_tab['supplieraddress'] = exp_df['EXPORTER_ADDRESS']  # 供应商地址
    target_tab['suppliercontact'] = exp_df['EXPORTER_TEL']  # 供应商联系方式
    target_tab['hscode'] = exp_df['HS_CODE']  # hs编码
    target_tab['hscodedescription'] = exp_df['HS_CODE_DESC']  # hs编码描述
    target_tab['commoditydescription'] = [str(x).replace("\"", " ") if x is not None else x for x in     exp_df['PRODUCT_DESC'].values]  # 产品描述
    # target_tab['totalcifvalue'] = exp_df['totalcifvalue']  # cif总价
    target_tab['totalfobvalue'] = exp_df['FOB']  # fob总价
    target_tab['grossweight'] = exp_df['G_WEIGHT']  # 毛重
    target_tab['netweight'] = exp_df['N_WEIGHT']  # 重量
    target_tab['quantity'] = exp_df['QUANTITY']  # 数量
    target_tab['quantityunit'] = exp_df['UNIT_OF_QUANTITY']  # 数量单位
    # target_tab['teu'] = exp_df['teu']  # TEU
    # target_tab['importer_forwarderagent'] = exp_df['importer_forwarderagent']  #  采购商货代公司标签
    # target_tab['supplier_forwarderagent'] = [0] * exp_df.shape[0]  # 供应商货代公司标签
    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签
    target_tab['abnormaldata'] = [0] * exp_df.shape[0]  # 是否命中异常数据规则
    # target_tab['portofloading'] = exp_df['portofloading']  # 启运港
    target_tab['portofdestination'] = exp_df['DEST_PORT']  # 目的港
    # target_tab['loadingcountrycode'] = exp_df['loadingcountrycode']  # 启运国国际编码
    # target_tab['loadingcountry'] = exp_df['loadingcountry']  # 启运国英文名称
    target_tab['transportterm'] = exp_df['TRANS_TYPE']  # 运输方式
    # target_tab['tradeterm'] = exp_df['INCOTERM']  # 成交方式
    # target_tab['paymentterm'] = exp_df['paymentterm']  # 付款方式
    # target_tab['carrier'] = exp_df['carrier']  # 承运人名称
    # target_tab['containerno'] = exp_df['containerno']  # 集装箱箱号
    target_tab['vesselname'] = exp_df['SHIP_NAME']  # 船名
    # target_tab['brand'] = exp_df['brand']  # 品牌
    target_tab['version'] = exp_df['version']  # 版本
    target_tab['country'] = exp_df['src_country']  # 国家
    # target_tab['IMPORTER_ID'] = exp_df['IMPORTER_ID']  # 渠道采购商编码
    target_tab['SUPPLIER_ID'] = exp_df['EXPORTER_ID']  # 渠道供应商编码
    # target_tab['cif_currency'] = 'USD'                         # cif货币类型
    target_tab['fob_currency'] = 'USD'                        # fob货币类型
    
    end=time.time()
    logger.info(f'Export data mapping and cleaning takes {round((end-start)/60,2)} minutes')
    
    return target_tab.loc[:,config.target_cols]


# 22
def PER_SEA_get_target_import(imp_path, src_cols):
    """
    秘鲁-海运 进口
    22	拉丁美洲	PERU_SEA	秘鲁-海运	PER_SEA
    """
    start=time.time()
    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    imp_df = pd.read_csv(imp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {imp_df.columns.values}')

    target_tab = pd.DataFrame(columns=config.target_cols)

    target_tab['channelno'] = ['zdzj'] * imp_df.shape[0]  # 渠道缩写
    target_tab['dataid']             = imp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = imp_df['iesign']                    # 进出口标志
    target_tab['datatype'] = ['B'] * imp_df.shape[0]  # 提单关单标志
    target_tab['writeoffflag'] = ['o'] * imp_df.shape[0]  # 冲销标志
    # target_tab['writeoffdataid'] = imp_df['writeoffdataid']  # 冲销记录主键
    target_tab['outputdate'] = [f'{int(x[0]):04d}-{int(x[1]):02d}-{int(x[2]):02d}' for x in     imp_df.loc[:, ['YEAR', 'MONTH', 'DAY']].values]  # 日期
    target_tab['origincountrycode'] = imp_df['PROVENANCE COUNTRY']  # 原产国国际编码
    target_tab['origincountry'] = imp_df['PROVENANCE COUNTRY']  # 原产国英文名称
    target_tab['countrycodeofdelivery'] = ['PER_SEA'] * imp_df.shape[0] # 目的国国际编码
    target_tab['countryofdelivery'] = ['PERU_SEA'] * imp_df.shape[0] # 目的国英文名称
    target_tab['importername'] = imp_df['IMPORTER']  # 采购商名称
    # target_tab['importeraddress'] = imp_df['importeraddress']  # 采购商地址
    # target_tab['importercontact'] = imp_df['importercontact']  # 采购商联系方式
    target_tab['suppliername'] = imp_df['SHIPPER']  # 供应商名称
    # target_tab['supplieraddress'] = imp_df['supplieraddress']  # 供应商地址
    # target_tab['suppliercontact'] = imp_df['suppliercontact']  # 供应商联系方式
    # target_tab['hscode'] = imp_df['hscode']  # hs编码
    # target_tab['hscodedescription'] = imp_df['hscodedescription']  # hs编码描述
    target_tab['commoditydescription'] = [str(x).replace("\"", " ") if x is not None else x for x in     imp_df['PRODUCT DESCRIPTION'].values]  # 产品描述
    # target_tab['totalcifvalue'] = imp_df['totalcifvalue']  # cif总价
    # target_tab['totalfobvalue'] = imp_df['totalfobvalue']  # fob总价
    target_tab['grossweight'] = imp_df['WEIGHT IN KG']  # 毛重
    target_tab['netweight'] = imp_df['WEIGHT IN KG']  # 重量
    target_tab['quantity'] = imp_df['PACKAGES QUANTITY']  # 数量
    # target_tab['quantityunit'] = imp_df['quantityunit']  # 数量单位
    target_tab['teu'] = imp_df['TEUS']  # TEU
    # target_tab['importer_forwarderagent'] = [0] * imp_df.shape[0]  # 采购商货代公司标签
    # target_tab['supplier_forwarderagent'] = imp_df['supplier_forwarderagent']  #  供应商货代公司标签
    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签
    target_tab['abnormaldata'] = [0] * imp_df.shape[0]  # 是否命中异常数据规则
    target_tab['portofloading'] = imp_df['SHIPPING PORT']  # 启运港
    target_tab['portofdestination'] = imp_df['DOWNLOAD PORT']  # 目的港
    target_tab['loadingcountrycode'] = imp_df['SHIPPING COUNTRY']  # 启运国国际编码
    # target_tab['loadingcountry'] = imp_df['loadingcountry']  # 启运国英文名称
    # target_tab['transportterm'] = imp_df['transportterm']  # 运输方式
    target_tab['tradeterm'] = imp_df['INCOTERMS']  # 成交方式
    # target_tab['paymentterm'] = imp_df['paymentterm']  # 付款方式
    # target_tab['carrier'] = imp_df['carrier']  # 承运人名称
    # target_tab['containerno'] = imp_df['containerno']  # 集装箱箱号
    # target_tab['vesselname'] = imp_df['vesselname']  # 船名
    # target_tab['brand'] = imp_df['brand']  # 品牌
    target_tab['version'] = imp_df['version']  # 版本
    target_tab['country'] = imp_df['src_country']  # 国家
    # target_tab['IMPORTER ID'] = imp_df['IMPORTER_ID']  # 渠道采购商编码
    # target_tab['SUPPLIER ID'] = imp_df['SUPPLIER_ID']  # 渠道供应商编码
    # target_tab['cif_currency'] = 'USD'                         # cif货币类型
    # target_tab['fob_currency'] = 'USD'                        # fob货币类型

    end=time.time()
    logger.info(f'Import data mapping and cleaning takes {round((end-start)/60,2)} minutes')

    return target_tab.loc[:,config.target_cols]

def PER_SEA_get_target_export(exp_path, src_cols):
    """
    秘鲁-海运 出口
    22	拉丁美洲	PERU_SEA	秘鲁-海运	PER_SEA
    """
    start=time.time()
    
    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    exp_df = pd.read_csv(exp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {exp_df.columns.values}')

    target_tab = pd.DataFrame(columns=config.target_cols)

    target_tab['channelno'] = ['zdzj'] * exp_df.shape[0]  # 渠道缩写
    target_tab['dataid']             = exp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = exp_df['iesign']                    # 进出口标志
    target_tab['datatype'] = ['B'] * exp_df.shape[0]  # 提单关单标志
    target_tab['writeoffflag'] = ['o'] * exp_df.shape[0]  # 冲销标志
    # target_tab['writeoffdataid'] = exp_df['writeoffdataid']  # 冲销记录主键
    target_tab['outputdate'] = [f'{int(x[0]):04d}-{int(x[1]):02d}-{int(x[2]):02d}' for x in exp_df.loc[:, ['YEAR', 'MONTH', 'DAY']].values]  # 日期
    target_tab['origincountrycode'] = ['PER_SEA'] * exp_df.shape[0]  # 原产国国际编码
    target_tab['origincountry'] = ['PERU_SEA'] * exp_df.shape[0]  # 原产国英文名称
    target_tab['countrycodeofdelivery'] = exp_df['FINAL COUNTRY']  # 目的国国际编码
    target_tab['countryofdelivery'] = exp_df['FINAL COUNTRY']  # 目的国英文名称
    # target_tab['importername'] = exp_df['importername']  # 采购商名称
    target_tab['importeraddress'] = exp_df['CONSIGNEE']  # 采购商地址
    # target_tab['importercontact'] = exp_df['importercontact']  # 采购商联系方式
    # target_tab['suppliername'] = exp_df['suppliername']  # 供应商名称
    target_tab['supplieraddress'] = exp_df['SHIPPER']  # 供应商地址
    # target_tab['suppliercontact'] = exp_df['suppliercontact']  # 供应商联系方式
    # target_tab['hscode'] = exp_df['hscode']  # hs编码
    # target_tab['hscodedescription'] = exp_df['hscodedescription']  # hs编码描述
    target_tab['commoditydescription'] = [str(x).replace("\"", " ") if x is not None else x for x in exp_df['PRODUCT DESCRIPTION'].values]  # 产品描述
    # target_tab['totalcifvalue'] = exp_df['totalcifvalue']  # cif总价
    # target_tab['totalfobvalue'] = exp_df['totalfobvalue']  # fob总价
    target_tab['grossweight'] = exp_df['WEIGHT IN KG']  # 毛重
    target_tab['netweight'] = exp_df['WEIGHT IN KG']  # 重量
    target_tab['quantity'] = exp_df['PACKAGES QUANTITY']  # 数量
    # target_tab['quantityunit'] = exp_df['quantityunit']  # 数量单位
    target_tab['teu'] = exp_df['TEUS']  # TEU
    # target_tab['importer_forwarderagent'] = exp_df['importer_forwarderagent']  #  采购商货代公司标签
    # target_tab['supplier_forwarderagent'] = [0] * exp_df.shape[0]  # 供应商货代公司标签
    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签
    target_tab['abnormaldata'] = [0] * exp_df.shape[0]  # 是否命中异常数据规则
    target_tab['portofloading'] = exp_df['LOADING PORT']  # 启运港
    target_tab['portofdestination'] = exp_df['FINAL PORT']  # 目的港
    # target_tab['loadingcountrycode'] = exp_df['loadingcountrycode']  # 启运国国际编码
    # target_tab['loadingcountry'] = exp_df['loadingcountry']  # 启运国英文名称
    # target_tab['transportterm'] = exp_df['transportterm']  # 运输方式
    # target_tab['tradeterm'] = exp_df['tradeterm']  # 成交方式
    # target_tab['paymentterm'] = exp_df['paymentterm']  # 付款方式
    # target_tab['carrier'] = exp_df['carrier']  # 承运人名称
    # target_tab['containerno'] = exp_df['containerno']  # 集装箱箱号
    # target_tab['vesselname'] = exp_df['vesselname']  # 船名
    # target_tab['brand'] = exp_df['brand']  # 品牌
    target_tab['version'] = exp_df['version']  # 版本
    target_tab['country'] = exp_df['src_country']  # 国家
    # target_tab['IMPORTER ID'] = exp_df['IMPORTER_ID']  # 渠道采购商编码
    # target_tab['SUPPLIER ID'] = exp_df['SUPPLIER_ID']  # 渠道供应商编码
    # target_tab['cif_currency'] = 'USD'                         # cif货币类型
    # target_tab['fob_currency'] = 'USD'                        # fob货币类型
    
    end=time.time()
    logger.info(f'Export data mapping and cleaning takes {round((end-start)/60,2)} minutes')

    return target_tab.loc[:,config.target_cols]



# 23
def PER_AIR_get_target_import(imp_path, src_cols):
    """
    秘鲁-空运 进口
    23	拉丁美洲	PERU_AIR	秘鲁-空运	PER_AIR
    """
    start=time.time()
    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    imp_df = pd.read_csv(imp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {imp_df.columns.values}')
    
    target_tab = pd.DataFrame(columns=config.target_cols)
    
    target_tab['channelno'] = ['zdzj'] * imp_df.shape[0]  # 渠道缩写
    target_tab['dataid']             = imp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = imp_df['iesign']                    # 进出口标志
    target_tab['datatype'] = ['B'] * imp_df.shape[0]  # 提单关单标志
    target_tab['writeoffflag'] = ['o'] * imp_df.shape[0]  # 冲销标志
    # target_tab['writeoffdataid'] = imp_df['writeoffdataid']  # 冲销记录主键
    target_tab['outputdate'] = [f'{int(x[0]):04d}-{int(x[1]):02d}-{int(x[2]):02d}' for x in imp_df.loc[:,['YEAR', 'MONTH', 'DAY']].values]  # 日期
    # target_tab['origincountrycode'] = imp_df['ORIGIN_COUNTRY']  # 原产国国际编码
    # target_tab['origincountry'] = imp_df['ORIGIN_COUNTRY']  # 原产国英文名称
    target_tab['countrycodeofdelivery'] = ['PER_AIR'] * imp_df.shape[0] # 目的国国际编码
    target_tab['countryofdelivery'] = ['PERU_AIR'] * imp_df.shape[0] # 目的国英文名称
    target_tab['importername'] = imp_df['IMPORTER']  # 采购商名称
    # target_tab['importeraddress'] = imp_df['importeraddress']  # 采购商地址
    # target_tab['importercontact'] = imp_df['importercontact']  # 采购商联系方式
    target_tab['suppliername'] = imp_df['SHIPPER']  # 供应商名称
    # target_tab['supplieraddress'] = imp_df['supplieraddress']  # 供应商地址
    # target_tab['suppliercontact'] = imp_df['suppliercontact']  # 供应商联系方式
    # target_tab['hscode'] = imp_df['hscode']  # hs编码
    # target_tab['hscodedescription'] = imp_df['hscodedescription']  # hs编码描述
    # target_tab['commoditydescription'] = [x.replace("\"", " ") if x is not None else x for x in     imp_df['PRODUCT_DESC'].values]  # 产品描述
    # target_tab['totalcifvalue'] = imp_df['totalcifvalue']  # cif总价
    # target_tab['totalfobvalue'] = imp_df['totalfobvalue']  # fob总价
    # target_tab['grossweight'] = imp_df['WEIGHT KG']  # 毛重
    # target_tab['netweight'] = imp_df['netweight']  # 重量
    # target_tab['quantity'] = imp_df['PACKAGES QUANTITY']  # 数量
    # target_tab['quantityunit'] = imp_df['quantityunit']  # 数量单位
    # target_tab['teu'] = imp_df['teu']  # TEU
    # target_tab['importer_forwarderagent'] = [0] * imp_df.shape[0]  # 采购商货代公司标签
    # target_tab['supplier_forwarderagent'] = imp_df['supplier_forwarderagent']  #  供应商货代公司标签
    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签
    # target_tab['abnormaldata'] = [0] * imp_df.shape[0]  # 是否命中异常数据规则
    # target_tab['portofloading'] = imp_df['ORIGIN CITY']  # 启运港
    # target_tab['portofdestination'] = imp_df['PORT OF DESTINATION']  # 目的港
    # target_tab['loadingcountrycode'] = imp_df['loadingcountrycode']  # 启运国国际编码
    # target_tab['loadingcountry'] = imp_df['loadingcountry']  # 启运国英文名称
    # target_tab['transportterm'] = imp_df['transportterm']  # 运输方式
    # target_tab['tradeterm'] = imp_df['INCOTERMS']  # 成交方式
    # target_tab['paymentterm'] = imp_df['paymentterm']  # 付款方式
    # target_tab['carrier'] = imp_df['carrier']  # 承运人名称
    # target_tab['containerno'] = imp_df['containerno']  # 集装箱箱号
    # target_tab['vesselname'] = imp_df['vesselname']  # 船名
    # target_tab['brand'] = imp_df['brand']  # 品牌
    target_tab['version'] = imp_df['version']  # 版本
    target_tab['country'] = imp_df['src_country']  # 国家
    # target_tab['IMPORTER_ID'] = imp_df['IMPORTER ID']  # 渠道采购商编码
    # target_tab['SUPPLIER_ID'] = imp_df['SUPPLIER ID']  # 渠道供应商编码
    # target_tab['cif_currency'] = 'USD'                         # cif货币类型
    # target_tab['fob_currency'] = 'USD'                        # fob货币类型
    
    end=time.time()
    logger.info(f'Import data mapping and cleaning takes {round((end-start)/60,2)} minutes')
    
    return target_tab.loc[:,config.target_cols]

def PER_AIR_get_target_export(exp_path, src_cols):
    """
    秘鲁-空运 出口
    23	拉丁美洲	PERU_AIR	秘鲁-空运	PER_AIR
    """
    start=time.time()
    
    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    exp_df = pd.read_csv(exp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {exp_df.columns.values}')
    
    target_tab = pd.DataFrame(columns=config.target_cols)
    
    target_tab['channelno'] = ['zdzj'] * exp_df.shape[0]  # 渠道缩写
    target_tab['dataid']             = exp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = exp_df['iesign']                    # 进出口标志
    target_tab['datatype'] = ['B'] * exp_df.shape[0]  # 提单关单标志
    target_tab['writeoffflag'] = ['o'] * exp_df.shape[0]  # 冲销标志
    # target_tab['writeoffdataid'] = exp_df['writeoffdataid']  # 冲销记录主键
    target_tab['outputdate'] = [f'{int(x[0]):04d}-{int(x[1]):02d}-{int(x[2]):02d}' for x in exp_df.loc[:, ['YEAR', 'MONTH', 'DAY']].values]  # 日期
    target_tab['origincountrycode'] = ['PER_AIR'] * exp_df.shape[0]  # 原产国国际编码
    target_tab['origincountry'] = ['PERU_AIR'] * exp_df.shape[0]  # 原产国英文名称
    # target_tab['countrycodeofdelivery'] = exp_df['COUNTRY OF DESTINATION']  # 目的国国际编码
    # target_tab['countryofdelivery'] = exp_df['COUNTRY OF DESTINATION']  # 目的国英文名称
    target_tab['importername'] = exp_df['CONSIGNEE']  # 采购商名称
    # target_tab['importeraddress'] = exp_df['importeraddress']  # 采购商地址
    # target_tab['importercontact'] = exp_df['importercontact']  # 采购商联系方式
    target_tab['suppliername'] = exp_df['EXPORTER']  # 供应商名称
    # target_tab['supplieraddress'] = exp_df['supplieraddress']  # 供应商地址
    # target_tab['suppliercontact'] = exp_df['suppliercontact']  # 供应商联系方式
    # target_tab['hscode'] = exp_df['hscode']  # hs编码
    # target_tab['hscodedescription'] = exp_df['hscodedescription']  # hs编码描述
    # target_tab['commoditydescription'] = [x.replace("\"", " ") if x is not None else x for x in exp_df['PRODUCT_DESC'].values]  # 产品描述
    # target_tab['totalcifvalue'] = exp_df['totalcifvalue']  # cif总价
    # target_tab['totalfobvalue'] = exp_df['totalfobvalue']  # fob总价
    # target_tab['grossweight'] = exp_df['WEIGHT KG']  # 毛重
    # target_tab['netweight'] = exp_df['netweight']  # 重量
    # target_tab['quantity'] = exp_df['PACKAGES QUANTITY']  # 数量
    # target_tab['quantityunit'] = exp_df['quantityunit']  # 数量单位
    # target_tab['teu'] = exp_df['teu']  # TEU
    # target_tab['importer_forwarderagent'] = exp_df['importer_forwarderagent']  #  采购商货代公司标签
    # target_tab['supplier_forwarderagent'] = [0] * exp_df.shape[0]  # 供应商货代公司标签
    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签
    # target_tab['abnormaldata'] = [0] * exp_df.shape[0]  # 是否命中异常数据规则
    # target_tab['portofloading'] = exp_df['portofloading']  # 启运港
    # target_tab['portofdestination'] = exp_df['CITY OF DESTINATION']  # 目的港
    # target_tab['loadingcountrycode'] = exp_df['loadingcountrycode']  # 启运国国际编码
    # target_tab['loadingcountry'] = exp_df['loadingcountry']  # 启运国英文名称
    # target_tab['transportterm'] = exp_df['transportterm']  # 运输方式
    # target_tab['tradeterm'] = exp_df['tradeterm']  # 成交方式
    # target_tab['paymentterm'] = exp_df['paymentterm']  # 付款方式
    # target_tab['carrier'] = exp_df['carrier']  # 承运人名称
    # target_tab['containerno'] = exp_df['containerno']  # 集装箱箱号
    # target_tab['vesselname'] = exp_df['vesselname']  # 船名
    # target_tab['brand'] = exp_df['brand']  # 品牌
    target_tab['version'] = exp_df['version']  # 版本
    target_tab['country'] = exp_df['src_country']  # 国家
    # target_tab['IMPORTER_ID'] = exp_df['IMPORTER ID']  # 渠道采购商编码
    # target_tab['SUPPLIER_ID'] = exp_df['SUPPLIER ID']  # 渠道供应商编码
    # target_tab['cif_currency'] = 'USD'                         # cif货币类型
    # target_tab['fob_currency'] = 'USD'                        # fob货币类型
    
    end=time.time()
    logger.info(f'Export data mapping and cleaning takes {round((end-start)/60,2)} minutes')
    
    return target_tab.loc[:,config.target_cols]


# 24
def MEX_get_target_import(imp_path, src_cols):
    """
    墨西哥 进口
    24	拉丁美洲	MEXICO	墨西哥	MEX
    """
    start=time.time()
    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    imp_df = pd.read_csv(imp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {imp_df.columns.values}')

    target_tab = pd.DataFrame(columns=config.target_cols)

    target_tab['channelno'] = ['zdzj']*imp_df.shape[0] # 渠道缩写
    target_tab['dataid']             = imp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = imp_df['iesign']                    # 进出口标志
    target_tab['datatype'] = ['D'] * imp_df.shape[0] # 提单关单标志
    target_tab['writeoffflag'] = ['o']*imp_df.shape[0] # 冲销标志
    # target_tab['writeoffdataid'] = imp_df['aaa'] # 冲销记录主键

    # target_tab['outputdate'] = imp_df['REG_DATE'] # 日期
    target_tab['outputdate'] =  pd.to_datetime(imp_df['REG_DATE'], format='mixed').dt.strftime('%Y-%m-%d').values    # 日期
    
    target_tab['origincountrycode'] = imp_df['ORIGIN_COUNTRY'] # 原产国国际编码
    target_tab['origincountry'] = imp_df['ORIGIN_COUNTRY'] # 原产国英文名称
    target_tab['countrycodeofdelivery'] = ['MEX'] * imp_df.shape[0] # 目的国国际编码
    target_tab['countryofdelivery'] = ['MEXICO'] * imp_df.shape[0] # 目的国英文名称
    target_tab['importername'] = imp_df['IMPORTER_NAME'] # 采购商名称
    target_tab['importeraddress'] = imp_df['IMPORTER_ADDRESS'] # 采购商地址
    # target_tab['importercontact'] = imp_df['aaaaa'] # 采购商联系方式
    target_tab['suppliername'] = imp_df['SUPPLIER_NAME'] # 供应商名称
    # target_tab['supplieraddress'] = imp_df['aaaaa'] # 供应商地址
    # target_tab['suppliercontact'] = imp_df['aaaaa'] # 供应商联系方式
    target_tab['hscode'] = imp_df['HS_CODE'] # hs编码
    # target_tab['hscodedescription'] = imp_df['aaaaa'] # hs编码描述
    # target_tab['commoditydescription'] = imp_df['PRODUCT_DESC'] # 产品描述
    target_tab['commoditydescription'] = [str(x).replace("\"", " ") if x is not None else x for x in imp_df['PRODUCT_DESC'].values] # 产品描述
    target_tab['totalcifvalue'] = imp_df['US_CIF'] # cif总价
    # target_tab['totalfobvalue'] = imp_df['aaaaa'] # fob总价
    target_tab['grossweight'] = imp_df['G_WEIGHT'] # 毛重
    # target_tab['netweight'] = imp_df['aaaaa'] # 重量
    target_tab['quantity'] = imp_df['QUANTITY'] # 数量
    target_tab['quantityunit'] = imp_df['UNIT_OF_QUANTITY'] # 数量单位
    # target_tab['teu'] = imp_df['aaaaa'] # TEU
    # target_tab['importer_forwarderagent'] = imp_df['aaaaa'] # 采购商货代公司标签
    # target_tab['supplier_forwarderagent'] = imp_df['aaaaa'] # 供应商货代公司标签
    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签
    # target_tab['abnormaldata'] = imp_df['aaaaa'] # 是否命中异常数据规则
    target_tab['CUSTOMS_STATE_PORT'] = imp_df['CUSTOMS_STATE_PORT'] # 启运港
    # target_tab['portofdestination'] = imp_df['aaaaa'] # 目的港
    # target_tab['loadingcountrycode'] = imp_df['aaaaa'] # 启运国国际编码
    # target_tab['loadingcountry'] = imp_df['aaaaa'] # 启运国英文名称
    target_tab['transportterm'] = imp_df['TRANS_TYPE'] # 运输方式
    # target_tab['tradeterm'] = imp_df['aaaaa'] # 成交方式
    # target_tab['paymentterm'] = imp_df['aaaaa'] # 付款方式
    # target_tab['carrier'] = imp_df['aaaaa'] # 承运人名称
    # target_tab['containerno'] = imp_df['aaaaa'] # 集装箱箱号
    # target_tab['vesselname'] = imp_df['aaaaa'] # 船名
    # target_tab['brand'] = imp_df['aaaaa'] # 品牌
    target_tab['version'] = imp_df['version'] # 版本
    target_tab['country'] = imp_df['src_country'] # 国家
    # target_tab['IMPORTER_ID'] = imp_df['aaaaa'] # 渠道采购商编码
    # target_tab['SUPPLIER_ID'] = imp_df['aaaaa'] # 渠道供应商编码
    target_tab['cif_currency'] = 'USD'                         # cif货币类型
    # target_tab['fob_currency'] = 'USD'                        # fob货币类型


    end=time.time()
    logger.info(f'Import data mapping and cleaning takes {round((end-start)/60,2)} minutes')

    return target_tab.loc[:,config.target_cols]

def MEX_get_target_export(exp_path, src_cols):
    """
    墨西哥 出口
    24	拉丁美洲	MEXICO	墨西哥	MEX
    """
    start=time.time()
    
    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    exp_df = pd.read_csv(exp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {exp_df.columns.values}')

    target_tab = pd.DataFrame(columns=config.target_cols)

    target_tab['channelno'] = ['zdzj']*exp_df.shape[0] # 渠道缩写
    target_tab['dataid']             = exp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = exp_df['iesign']                    # 进出口标志
    target_tab['datatype'] = ['D'] * exp_df.shape[0] # 提单关单标志
    target_tab['writeoffflag'] = ['o']*exp_df.shape[0] # 冲销标志
    # target_tab['writeoffdataid'] = exp_df['aaa'] # 冲销记录主键

    target_tab['outputdate'] = pd.to_datetime(exp_df['REG_DATE'], format='mixed').dt.strftime('%Y-%m-%d').values # 日期
    target_tab['origincountrycode'] = ['MEX'] * exp_df.shape[0]  # 原产国国际编码
    target_tab['origincountry'] = ['MEXICO'] * exp_df.shape[0]  # 原产国英文名称
    target_tab['countrycodeofdelivery'] = exp_df['DEST_COUNTRY'] # 目的国国际编码
    target_tab['countryofdelivery'] = exp_df['DEST_COUNTRY'] # 目的国英文名称
    target_tab['importername'] = exp_df['BUYER_NAME'] # 采购商名称
    # target_tab['importeraddress'] = exp_df['aaaaa'] # 采购商地址
    # target_tab['importercontact'] = exp_df['aaaaa'] # 采购商联系方式
    target_tab['suppliername'] = exp_df['EXPORTER_NAME'] # 供应商名称
    target_tab['supplieraddress'] = exp_df['EXPORTER_ADDRESS'] # 供应商地址
    # target_tab['suppliercontact'] = exp_df['aaaaa'] # 供应商联系方式
    target_tab['hscode'] = exp_df['HS_CODE'] # hs编码
    # target_tab['hscodedescription'] = exp_df['aaaaa'] # hs编码描述
    target_tab['commoditydescription'] = [str(x).replace("\"", " ") if x is not None else x for x in exp_df['PRODUCT_DESC'].values] # 产品描述
    # target_tab['totalcifvalue'] = exp_df['aaaaa'] # cif总价
    target_tab['totalfobvalue'] = exp_df['US_FOB'] # fob总价
    target_tab['grossweight'] = exp_df['G_WEIGHT'] # 毛重
    # target_tab['netweight'] = exp_df['aaaaa'] # 重量
    target_tab['quantity'] = exp_df['QUANTITY'] # 数量
    target_tab['quantityunit'] = exp_df['UNIT_OF_QUANTITY'] # 数量单位
    # target_tab['teu'] = exp_df['aaaaa'] # TEU
    # target_tab['importer_forwarderagent'] = exp_df['aaaaa'] # 采购商货代公司标签
    # target_tab['supplier_forwarderagent'] = exp_df['aaaaa'] # 供应商货代公司标签
    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签
    # target_tab['abnormaldata'] = exp_df['aaaaa'] # 是否命中异常数据规则
    # target_tab['portofloading'] = exp_df['aaaaa'] # 启运港
    target_tab['portofdestination'] = exp_df['CUSTOMS_STATE_PORT'] # 目的港
    # target_tab['loadingcountrycode'] = exp_df['aaaaa'] # 启运国国际编码
    # target_tab['loadingcountry'] = exp_df['aaaaa'] # 启运国英文名称
    target_tab['transportterm'] = exp_df['TRANS_TYPE'] # 运输方式
    # target_tab['tradeterm'] = exp_df['aaaaa'] # 成交方式
    # target_tab['paymentterm'] = exp_df['aaaaa'] # 付款方式
    # target_tab['carrier'] = exp_df['aaaaa'] # 承运人名称
    # target_tab['containerno'] = exp_df['aaaaa'] # 集装箱箱号
    # target_tab['vesselname'] = exp_df['aaaaa'] # 船名
    # target_tab['brand'] = exp_df['aaaaa'] # 品牌
    target_tab['version'] = exp_df['version'] # 版本
    target_tab['country'] = exp_df['src_country'] # 国家
    # target_tab['IMPORTER_ID'] = exp_df['aaaaa'] # 渠道采购商编码
    # target_tab['SUPPLIER_ID'] = exp_df['aaaaa'] # 渠道供应商编码
    # target_tab['cif_currency'] = 'USD'                         # cif货币类型
    target_tab['fob_currency'] = 'USD'                        # fob货币类型

    end=time.time()
    logger.info(f'Export data mapping and cleaning takes {round((end-start)/60,2)} minutes')

    return target_tab.loc[:,config.target_cols]


# 25
def NAM_get_target_import(imp_path, src_cols):
    """
    纳米比亚 进口
    25	非洲	NAMIBIA	纳米比亚	NAM
    """
    start=time.time()

    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    imp_df = pd.read_csv(imp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {imp_df.columns.values}')

    target_tab = pd.DataFrame(columns=config.target_cols)
    
    target_tab['channelno'] = ['zdzj']*imp_df.shape[0] # 渠道缩写
    target_tab['dataid']             = imp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = imp_df['iesign']                    # 进出口标志
    target_tab['datatype'] = ['D'] * imp_df.shape[0] # 提单关单标志
    target_tab['writeoffflag'] = ['o']*imp_df.shape[0] # 冲销标志
    # target_tab['writeoffdataid'] = imp_df[''] # 冲销记录主键
    
    target_tab['outputdate'] = pd.to_datetime(imp_df['REG_DATE'], format='mixed').dt.strftime('%Y-%m-%d').values # 日期
    #target_tab['origincountrycode'] = imp_df['aaaaa'] # 原产国国际编码
    #target_tab['origincountry'] = imp_df['aaaaa'] # 原产国英文名称
    target_tab['countrycodeofdelivery'] = ['NAM'] * imp_df.shape[0] # 目的国国际编码
    target_tab['countryofdelivery'] = ['NAMIBIA'] * imp_df.shape[0] # 目的国英文名称
    target_tab['importername'] = imp_df['IMPORTER_NAME'] # 采购商名称
    target_tab['importeraddress'] = imp_df['IMPORTER_NAME'] # 采购商地址
    target_tab['importercontact'] = imp_df['IMPORTER_NAME'] # 采购商联系方式
    target_tab['suppliername'] = imp_df['EXPORTER_NAME'] # 供应商名称
    target_tab['supplieraddress'] = imp_df['EXPORTER_NAME'] # 供应商地址
    target_tab['suppliercontact'] = imp_df['EXPORTER_NAME'] # 供应商联系方式
    target_tab['hscode'] = imp_df['HS_CODE'] # hs编码
    target_tab['hscodedescription'] = imp_df['HS_CODE_DESC'] # hs编码描述
    # target_tab['commoditydescription'] = imp_df['aaaaa'] # 产品描述
    target_tab['totalcifvalue'] = imp_df['CIF'] # cif总价
    target_tab['totalfobvalue'] = imp_df['FOB'] # fob总价
    target_tab['grossweight'] = imp_df['G_WEIGHT_IN_KG'] # 毛重
    # target_tab['netweight'] = imp_df['N_WEIGH_IN_KG'] # 重量
    # target_tab['quantity'] = imp_df['aaaaa'] # 数量
    # target_tab['quantityunit'] = imp_df['aaaaa'] # 数量单位
    # target_tab['teu'] = imp_df['aaaaa'] # TEU
    target_tab['importer_forwarderagent'] = [0] * imp_df.shape[0] # 采购商货代公司标签
    # target_tab['supplier_forwarderagent'] = imp_df['aaaaa'] # 供应商货代公司标签
    target_tab['abnormaldata']            = [0] * imp_df.shape[0] # 是否命中异常数据规则
    # target_tab['portofloading'] = imp_df['aaaaa'] # 启运港
    # target_tab['portofdestination'] = imp_df['aaaaa'] # 目的港
    # target_tab['loadingcountrycode'] = imp_df['aaaaa'] # 启运国国际编码
    # target_tab['loadingcountry'] = imp_df['aaaaa'] # 启运国英文名称
    # target_tab['transportterm'] = imp_df['aaaaa'] # 运输方式
    # target_tab['tradeterm'] = imp_df['aaaaa'] # 成交方式
    # target_tab['paymentterm'] = imp_df['aaaaa'] # 付款方式
    # target_tab['carrier'] = imp_df['aaaaa'] # 承运人名称
    # target_tab['containerno'] = imp_df['aaaaa'] # 集装箱箱号
    # target_tab['vesselname'] = imp_df['aaaaa'] # 船名
    # target_tab['brand'] = imp_df['aaaaa'] # 品牌
    target_tab['version'] = imp_df['version'] # 版本
    target_tab['country'] = imp_df['src_country'] # 国家
    target_tab['IMPORTER_ID'] = imp_df['IMPORTER_ID'] # 渠道采购商编码
    # target_tab['SUPPLIER_ID'] = imp_df['aaaaa'] # 渠道供应商编码
    target_tab['cif_currency'] = 'USD'                         # cif货币类型
    target_tab['fob_currency'] = 'USD'                        # fob货币类型
    
    end=time.time()
    logger.info(f'Import data mapping and cleaning takes {round((end-start)/60,2)} minutes')
    
    return target_tab.loc[:,config.target_cols]

# 26
def NGA_get_target_import(imp_path, src_cols):
    """
    尼日利亚    进口
    26	非洲	NIGERIA	尼日利亚	NGA
    """
    start=time.time()
    
    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    imp_df = pd.read_csv(imp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {imp_df.columns.values}')

    target_tab = pd.DataFrame(columns=config.target_cols)

    target_tab['channelno'] = ['zdzj'] * imp_df.shape[0] # 渠道缩写
    target_tab['dataid']             = imp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = imp_df['iesign']                    # 进出口标志
    target_tab['datatype']  = ['D'] * imp_df.shape[0] # 提单关单标志
    target_tab['writeoffflag'] = ['o'] * imp_df.shape[0] # 冲销标志
    target_tab['writeoffdataid'] = None # 冲销记录主键
    target_tab['outputdate'] = pd.to_datetime(imp_df['REG_DATE'], format='%y%m%d', errors='coerce').dt.strftime('%Y-%m-%d') # 日期
    target_tab['origincountrycode'] = imp_df['ORIGIN_COUNTRY'] # 原产国国际编码
    target_tab['origincountry']     = imp_df['ORIGIN_COUNTRY'] # 原产国英文名称
    target_tab['countrycodeofdelivery'] = ['NGA'] * imp_df.shape[0] # 目的国国际编码
    target_tab['countryofdelivery'] = ['NIGERIA'] * imp_df.shape[0] # 目的国英文名称
    target_tab['importername']   = imp_df['IMPORTER_NAME'] # 采购商名称
    target_tab['importeraddress']= imp_df['IMPORTER_NAME'] # 采购商地址
    target_tab['importercontact']= imp_df['IMPORTER_NAME'] # 采购商联系方式
    target_tab['suppliername']      = imp_df['EXPORTER_NAME'] # 供应商名称
    target_tab['supplieraddress']   = imp_df['EXPORTER_NAME'] # 供应商地址
    target_tab['suppliercontact']   = imp_df['EXPORTER_NAME'] # 供应商联系方式
    target_tab['hscode']            = imp_df['HS_CODE'] # hs编码
    target_tab['hscodedescription'] = imp_df['HS_CODE_DESC'] # hs编码描述
    # target_tab['commoditydescription'] = imp_df['aaaaa'] # 产品描述
    target_tab['totalcifvalue'] = imp_df['CIF_IN_USD'] # cif总价
    target_tab['totalfobvalue'] = imp_df['FOB_IN_USD'] # fob总价
    # target_tab['grossweight'] = imp_df['aaaaa'] # 毛重
    target_tab['netweight']     = imp_df['N_WEIGH_IN_KG'] # 重量
    # target_tab['quantity'] = imp_df['aaaaa'] # 数量
    # target_tab['quantityunit'] = imp_df['aaaaa'] # 数量单位
    # target_tab['teu'] = imp_df['aaaaa'] # TEU
    target_tab['importer_forwarderagent'] = [0]*imp_df.shape[0] # 采购商货代公司标签
    # target_tab['supplier_forwarderagent'] = imp_df['aaaaa'] # 供应商货代公司标签
    target_tab['abnormaldata']            = [0]*imp_df.shape[0] # 是否命中异常数据规则
    # target_tab['portofloading'] = imp_df['aaaaa'] # 启运港
    # target_tab['portofdestination'] = imp_df['aaaaa'] # 目的港
    # target_tab['loadingcountrycode'] = imp_df['EXPORTER_NAME'] # 启运国国际编码
    # target_tab['loadingcountry']     = imp_df['EXPORTER_NAME'] # 启运国英文名称
    # target_tab['transportterm'] = imp_df['aaaaa'] # 运输方式
    # target_tab['tradeterm'] = imp_df['aaaaa'] # 成交方式
    # target_tab['paymentterm'] = imp_df['aaaaa'] # 付款方式
    # target_tab['carrier'] = imp_df['aaaaa'] # 承运人名称
    target_tab['containerno']   = imp_df['CONTAINER_TYPE'] # 集装箱箱号
    # target_tab['vesselname']    = imp_df['VESSEL_NAME'] # 船名
    # target_tab['brand'] = imp_df['aaaaa'] # 品牌
    target_tab['version'] = imp_df['version'] # 版本
    target_tab['country'] = imp_df['src_country'] # 国家
    target_tab['IMPORTER_ID'] = imp_df['IMPORTER_ID'] # 渠道采购商编码
    # target_tab['SUPPLIER_ID'] = imp_df['aaaaa'] # 渠道供应商编码
    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签

    target_tab['cif_currency'] = 'USD'                         # cif货币类型
    target_tab['fob_currency'] = 'USD'                         # fob货币类型

    end=time.time()
    logger.info(f'Import data mapping and cleaning takes {round((end-start)/60,2)} minutes')

    return target_tab.loc[:,config.target_cols]

def NGA_get_target_export(exp_path, src_cols):
    """
    尼日利亚    出口
    26	非洲	NIGERIA	尼日利亚	NGA
    """
    start = time.time()
    
    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    exp_df = pd.read_csv(exp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {exp_df.columns.values}')

    target_tab = pd.DataFrame(columns=config.target_cols)

    target_tab['channelno'] = ['zdzj'] * exp_df.shape[0]  # 渠道缩写
    target_tab['dataid']             = exp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = exp_df['iesign']                    # 进出口标志
    target_tab['datatype'] = ['D'] * exp_df.shape[0]  # 提单关单标志
    target_tab['writeoffflag'] = ['o'] * exp_df.shape[0]  # 冲销标志
    target_tab['writeoffdataid'] = None  # 冲销记录主键
    # target_tab['outputdate'] = pd.to_datetime(exp_df['YEAR-MONTH'], format='%y%m', errors='coerce').dt.strftime('%Y-%m-01') # 日期
    target_tab['outputdate'] = [f'{int(x[0]):04d}-{int(x[1]):02d}-01' for x in exp_df.loc[:, ['YEAR', 'MONTH']].values]

    target_tab['origincountrycode'] = ['NGA'] * exp_df.shape[0]  # 原产国国际编码
    target_tab['origincountry'] = ['NIGERIA'] * exp_df.shape[0]  # 原产国英文名称

    # target_tab['countrycodeofdelivery'] = exp_df['aaaaa'] # 目的国国际编码
    # target_tab['countryofdelivery']     = exp_df['aaaaa'] # 目的国英文名称
    # target_tab['importername']   = exp_df['aaaaa'] # 采购商名称
    # target_tab['importeraddress']= exp_df['aaaaa'] # 采购商地址
    # target_tab['importercontact']= exp_df['aaaaa'] # 采购商联系方式

    target_tab['suppliername'] = exp_df['EXPORTER_NAME']  # 供应商名称
    target_tab['supplieraddress'] = exp_df['EXPORTER_NAME']  # 供应商地址
    target_tab['suppliercontact'] = exp_df['EXPORTER_NAME']  # 供应商联系方式

    target_tab['hscode'] = exp_df['HS_CODE']  # hs编码
    target_tab['hscodedescription'] = exp_df['HS_CODE_DESC']  # hs编码描述
    target_tab['commoditydescription'] = [str(x).replace('"', ' ') if pd.notnull(x) else x for x in exp_df['ITEMS']]  # 产品描述

    target_tab['totalcifvalue'] = exp_df['CIF_IN_NGN']  # cif总价
    # target_tab['totalfobvalue'] = exp_df['aaaaa'] # fob总价

    # target_tab['grossweight'] = exp_df['aaaaa'] # 毛重
    target_tab['netweight'] = exp_df['N_WEIGHT_IN_KG']  # 重量
    # target_tab['quantity'] = exp_df['aaaaa'] # 数量
    # target_tab['quantityunit'] = exp_df['aaaaa'] # 数量单位
    # target_tab['teu'] = exp_df['aaaaa'] # TEU

    # target_tab['importer_forwarderagent'] = exp_df['aaaaa'] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = [0] * exp_df.shape[0]  # 供应商货代公司标签
    target_tab['abnormaldata'] = [0] * exp_df.shape[0]  # 是否命中异常数据规则

    # target_tab['portofloading'] = exp_df['aaaaa'] # 启运港
    # target_tab['portofdestination'] = exp_df['aaaaa'] # 目的港
    # target_tab['loadingcountrycode'] = exp_df['EXPORTER_NAME']  # 启运国国际编码
    target_tab['loadingcountry'] = ['NIGERIA'] * exp_df.shape[0]  # 启运国英文名称

    # target_tab['transportterm'] = exp_df['aaaaa'] # 运输方式
    # target_tab['tradeterm'] = exp_df['aaaaa'] # 成交方式
    # target_tab['paymentterm'] = exp_df['aaaaa'] # 付款方式
    # target_tab['carrier'] = exp_df['aaaaa'] # 承运人名称
    # target_tab['containerno'] = exp_df['aaaaa'] # 集装箱箱号
    # target_tab['vesselname']    = exp_df['VESSEL_NAME'] # 船名

    # target_tab['brand'] = exp_df['aaaaa'] # 品牌
    target_tab['version'] = exp_df['version'] # 版本
    target_tab['country'] = exp_df['src_country'] # 国家
    # target_tab['IMPORTER_ID'] = exp_df['aaaaa'] # 渠道采购商编码
    # target_tab['SUPPLIER_ID'] = exp_df['aaaaa'] # 渠道供应商编码

    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签

    target_tab['cif_currency'] = 'NGN'                         # cif货币类型
    target_tab['fob_currency'] = 'NGN'                         # fob货币类型

    end = time.time()
    logger.info(f'Export data mapping and cleaning takes {round((end - start) / 60, 2)} minutes')

    return target_tab.loc[:,config.target_cols]


# 27
def LKA_get_target_import(imp_path, src_cols):
    """
    斯里兰卡 进口
    27	亚洲	SRI LANKA	斯里兰卡	LKA
    """
    start = time.time()
    
    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    imp_df = pd.read_csv(imp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {imp_df.columns.values}')
    
    target_tab = pd.DataFrame(columns=config.target_cols)
    
    # 基础字段
    target_tab['channelno'] = ['zdzj'] * imp_df.shape[0]  # 渠道编号
    target_tab['dataid']             = imp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = imp_df['iesign']                    # 进出口标志
    target_tab['writeoffflag'] = ['o'] * imp_df.shape[0]  # 核销标志
    target_tab['datatype'] = ['D'] * imp_df.shape[0]  # 数据类型
    
    # ----------------------------------------------------
    # 1. 基本信息
    target_tab['outputdate'] = pd.to_datetime(imp_df['REG_DATE'], format='mixed').dt.strftime('%Y-%m-%d').values  # 登记日期
    
    # 2. 国家信息（需要转写为标准英文国名）
    target_tab['origincountrycode'] = imp_df['FROM_COUNTRY']  # 起运国
    target_tab['origincountry'] = imp_df['FROM_COUNTRY']  # 起运国
    target_tab['countrycodeofdelivery'] = ['LKA'] * imp_df.shape[0] # 目的国国际编码
    target_tab['countryofdelivery'] = ['SRI LANKA'] * imp_df.shape[0] # 目的国英文名称
    
    # 3. 进口商信息
    target_tab['importername'] = imp_df['IMPORTER']  # 进口商
    target_tab['importeraddress'] = imp_df['IMPORTER_ADDRESS']  # 进口商地址
    
    # 4. 出口商信息
    target_tab['suppliername'] = imp_df['EXPORTER']  # 出口商
    target_tab['supplieraddress'] = imp_df['EXPORTER_ADDRESS']  # 出口商地址
    
    # 5. 产品信息
    target_tab['hscode'] = imp_df['HS_CODE']  # HS编码
    target_tab['commoditydescription'] = [str(x).replace("\"", " ") if x is not None else x for x in imp_df['PRODUCT_DESC'].values]  # 产品描述（处理引号）
    
    # 6. 价值重量信息
    target_tab['totalfobvalue'] = imp_df['ESTIMATE_VALUE_USD']  # 发票金额（本地货币）
    target_tab['grossweight'] = imp_df['G_WEIGHT_IN_KG']  # 毛重（千克）
    target_tab['netweight'] = imp_df['N_WEIGHT_IN_KG']  # 净重（千克）
    target_tab['quantity'] = imp_df['QUANTITY']  # 数量
    target_tab['quantityunit'] = imp_df['UNIT_OF_QUANTITY']  # 数量单位
    
    # 7. 运输信息
#     target_tab['importer_forwarderagent'] = [0] * imp_df.shape[0]  # 进口商代理（待判断）
    target_tab['abnormaldata'] = [0] * imp_df.shape[0]  # 异常数据（待判定）
    target_tab['loadingcountrycode'] = imp_df['FROM_COUNTRY']  # 起运国（需要转标准英文国名）
    target_tab['loadingcountry'] = imp_df['FROM_COUNTRY']  # 起运国（需要转标准英文国名）
    target_tab['transportterm'] = imp_df['TRANS_TYPE']  # 运输方式（需映射成统一枚举值）
    target_tab['vesselname'] = imp_df['VESSEL']  # 船名/航班号
    
    target_tab['country'] = imp_df['src_country'] # 国家
    target_tab['version']= imp_df['version']# 版本

    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签

    target_tab['cif_currency'] = 'USD'                         # cif货币类型
    target_tab['fob_currency'] = 'USD'                         # fob货币类型
    
    end = time.time()
    logger.info(f'Import data mapping and cleaning takes {round((end - start) / 60, 2)} minutes')
    return target_tab.loc[:,config.target_cols]

def LKA_get_target_export(exp_path, src_cols):
    """
    斯里兰卡 出口
    27	亚洲	SRI LANKA	斯里兰卡	LKA
    """
    start = time.time()
    
    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    exp_df = pd.read_csv(exp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {exp_df.columns.values}')
    
    target_tab = pd.DataFrame(columns=config.target_cols)
    
    # 基础字段
    target_tab['channelno'] = ['zdzj'] * exp_df.shape[0]  # 渠道编号
    target_tab['dataid']             = exp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = exp_df['iesign']                    # 进出口标志
    target_tab['writeoffflag'] = ['o'] * exp_df.shape[0]  # 核销标志
    target_tab['datatype'] = ['D'] * exp_df.shape[0]  # 数据类型
    
    # ----------------------------------------------------
    # 1. 基本信息
    target_tab['outputdate'] = pd.to_datetime(exp_df['REG_DATE'], format='mixed').dt.strftime('%Y-%m-%d').values  # 登记日期
    
    # 2. 国家信息
    target_tab['origincountrycode']  = ['LKA'] * exp_df.shape[0]           # 原产国国际编码
    target_tab['origincountry']      = ['SRI LANKA'] * exp_df.shape[0]        # 原产国英文名称
    target_tab['countrycodeofdelivery'] = exp_df['TO_COUNTRY']  # 目的国
    target_tab['countryofdelivery'] = exp_df['TO_COUNTRY']  # 目的国
    
    # 3. 进口商信息
    target_tab['importername'] = exp_df['IMPORTER']  # 进口商
    target_tab['importeraddress'] = exp_df['IMPORTER_ADDRESS']  # 进口商地址
    
    # 4. 出口商信息
    target_tab['suppliername'] = exp_df['EXPORTER']  # 出口商
    target_tab['supplieraddress'] = exp_df['EXPORTER_ADDRESS']  # 出口商地址
    
    # 5. 产品信息
    target_tab['hscode'] = exp_df['HS_CODE']  # HS编码
    # target_tab['hscodedescription'] = exp_df['HS_CODE_DESC']  # HS编码描述
    target_tab['commoditydescription'] = [str(x).replace("\"", " ") if x is not None else x for x in
                                          exp_df['PRODUCT_DESC'].values]  # 产品描述（处理引号）
    
    # 6. 价值重量信息
    target_tab['totalfobvalue'] = exp_df['ESTIMATE_VALUE_USD']  # 外汇发票金额
    target_tab['grossweight'] = exp_df['G_WEIGHT_IN_KG']  # 毛重（千克）
    target_tab['netweight'] = exp_df['N_WEIGHT_IN_KG']  # 净重（千克）
    target_tab['quantity'] = exp_df['QUANTITY']  # 数量
    target_tab['quantityunit'] = exp_df['UNIT_OF_QUANTITY']  # 数量单位
    
    # 7. 运输信息
#     target_tab['importer_forwarderagent'] = [0] * exp_df.shape[0]  # 进口商代理（待判断）
    target_tab['abnormaldata'] = [0] * exp_df.shape[0]  # 异常数据（待判定）
    target_tab['transportterm'] = exp_df['TRANS_TYPE']  # 运输类型（需映射成统一枚举值）
    target_tab['vesselname'] = exp_df['VESSEL']  # 船名
    target_tab['country'] = exp_df['TO_COUNTRY']  # 目的国
    
    target_tab['country'] = exp_df['src_country'] # 国家
    target_tab['version']= exp_df['version']# 版本

    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签

    target_tab['cif_currency'] = 'USD'                         # cif货币类型
    target_tab['fob_currency'] = 'USD'                         # fob货币类型
    
    end = time.time()
    logger.info(f'Export data mapping and cleaning takes {round((end - start) / 60, 2)} minutes')
    return target_tab.loc[:,config.target_cols]


# 28
def TZA_get_target_import(imp_path, src_cols):
    """
    坦桑尼亚 进口
    28	非洲	TANZANIA	坦桑尼亚	TZA
    """
    start = time.time()
    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    imp_df = pd.read_csv(imp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {imp_df.columns.values}')
    
    target_tab = pd.DataFrame(columns=config.target_cols)
    
    target_tab['channelno'] = ['zdzj'] * imp_df.shape[0]  # 渠道缩写
    target_tab['dataid']             = imp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = imp_df['iesign']                    # 进出口标志
    target_tab['writeoffflag'] = ['o'] * imp_df.shape[0]  # 冲销标志
    # target_tab['outputdate'] = [f'{int(x[0]):04d}-{int(x[1]):02d}-{int(x[2]):02d}' for x in imp_df.loc[:,['TANSAD_DATE']].values]
    target_tab['outputdate'] = pd.to_datetime(imp_df['TANSAD_DATE'], format='mixed').dt.strftime('%Y-%m-%d').values

    
    # 需要转写为标准英文国名
    target_tab['origincountrycode'] = imp_df['ORIGIN_COUNTRY']  # 原产国国际编码
    target_tab['origincountry'] = imp_df['ORIGIN_COUNTRY']  # 原产国英文名称
    target_tab['countrycodeofdelivery'] = ['TZA'] * imp_df.shape[0] # 目的国国际编码
    target_tab['countryofdelivery'] = ['TANZANIA'] * imp_df.shape[0] # 目的国英文名称
    target_tab['importername'] = imp_df['IMPORTER_NAME']  # 采购商名称
    target_tab['suppliername'] = imp_df['EXPORTER_NAME']# # 供应商名称
    # target tab['supplieraddress']= imp_df['aaa']# # 供应商地址
    # target tab['suppliercontact']= imp_df['aaa']# # 供应商联系方式
    target_tab['hscode'] = imp_df['HS_CODE']  # hs编码
    target_tab['hscodedescription'] = imp_df['HS_CODE_DESC']  # hs编码描述
    target_tab['commoditydescription'] = [str(x).replace("\"", " ") if x is not None else x for x in
                                          imp_df['PRODUCT_DESC'].values]  # 产品描述
    target_tab['totalcifvalue'] = imp_df['ITEM_CUSTOMS_CARGO_VALUE']  # cif总价
    target_tab['grossweight'] = imp_df['ITEM_G_WEIGHT']  # 毛重
    target_tab['netweight'] = imp_df['ITEM_N_WEIGHT']  # 重量
    target_tab['quantity'] = imp_df['QUANTITY']  # 数量
    target_tab['quantityunit'] = imp_df['UNIT_OF_MEASURE']  # 数量单位
    # 需要判断根据imp_df['IMPORTER']判断是否为0/1
    target_tab['importer_forwarderagent'] = [0] * imp_df.shape[0]
    # 待判定
    target_tab['abnormaldata'] = [0] * imp_df.shape[0]
    
    # target tab['teu']= imp df['aaaaa'] # TEU
    # target_tab['importer_forwarderagent']= imp_df['IMPORTER']# 采购商货代公司标签
    # target tab['supplier forwarderagent']= imp df['aaaaa']# 供应商货代公司标签
    # target_tab['abnormaldata']= imp_df['aaaaa']# 是否命中异常数据规则
    # target tab['portofdestination']= imp df['aaaaa']# 目的港
    target_tab['loadingcountrycode'] = imp_df['EXPORT_COUNTRY']
    target_tab['loadingcountry'] = imp_df['EXPORT_COUNTRY']
    # target tab['transportterm']= imp_df['aaaaa']# 运输方式
    # target tab['tradeterm']= imp df['aaaaa']# 成交方式
    # target_tab['paymentterm']= imp_df['aaaaa']# 付款方式
    # target_tab['carrier']= imp_df['aaaaa']# 承运人名称
    # target_tab['containerno']= imp_df['aaaaa']# 集装箱箱号
    # target_tab['vesselname']= imp_df['aaaaa']# 船名
    # target_tab['brand']= imp_df['aaaaa']# 品牌
    target_tab['version']= imp_df['version']# 版本
    target_tab['country']= imp_df['src_country']# 国家
    target_tab['IMPORTER_ID'] = imp_df['IMPORTER_TAX_ID']  # 渠道采购商编码

    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签

    target_tab['cif_currency'] = 'TZA'                         # cif货币类型
    target_tab['fob_currency'] = 'TZA'                         # fob货币类型
    
    target_tab['datatype'] = ['D'] * imp_df.shape[0]
    
    end = time.time()
    logger.info(f'Import data mapping and cleaning takes {round((end - start) / 60, 2)} minutes')
    
    return target_tab.loc[:,config.target_cols]

def TZA_get_target_export(exp_path, src_cols):
    """
    坦桑尼亚 出口
    28	非洲	TANZANIA	坦桑尼亚	TZA
    """
    start=time.time()

    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    exp_df = pd.read_csv(exp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {exp_df.columns.values}')
    
    target_tab = pd.DataFrame(columns=config.target_cols)
    target_tab['channelno'] = ['zdzj'] * exp_df.shape[0] # 渠道缩写
    target_tab['dataid']             = exp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = exp_df['iesign']                    # 进出口标志
    target_tab['datatype']  = ['D'] * exp_df.shape[0] # 提单关单标志
    target_tab['writeoffflag'] = ['o'] * exp_df.shape[0] # 冲销标志
    # target_tab['writeoffdataid'] = exp_df['aaa'] # 冲销记录主键
    
    target_tab['outputdate'] = pd.to_datetime(exp_df['TANSAD_DATE'], format='mixed').dt.strftime('%Y-%m-%d').values
    target_tab['origincountrycode']  = ['TZA'] * exp_df.shape[0]           # 原产国国际编码
    target_tab['origincountry']      = ['TANZANIA'] * exp_df.shape[0]        # 原产国英文名称
    target_tab['countrycodeofdelivery'] = exp_df['DEST_COUNTRY'] # 目的国国际编码
    target_tab['countryofdelivery']     = exp_df['DEST_COUNTRY'] # 目的国英文名称
    target_tab['importername']   = exp_df['IMPORTER_NAME'] # 采购商名称
    target_tab['importeraddress']= exp_df['IMPORTER_NAME'] # 采购商地址
    target_tab['importercontact']= exp_df['IMPORTER_NAME'] # 采购商联系方式
    target_tab['suppliername']      = exp_df['EXPORTER_NAME'] # 供应商名称
    target_tab['supplieraddress']   = exp_df['EXPORTER_NAME'] # 供应商地址
    target_tab['suppliercontact']   = exp_df['EXPORTER_NAME'] # 供应商联系方式
    target_tab['hscode']            = exp_df['HS_CODE'] # hs编码
    target_tab['hscodedescription'] = exp_df['HS_CODE_DESC'] # hs编码描述
    target_tab['commoditydescription'] = [str(x).replace('"', ' ') if pd.notnull(x) else x
                                          for x in exp_df['PRODUCT_DESC']] # 产品描述
    target_tab['totalcifvalue'] = exp_df['ITEM_CUSTOMS_CARGO_VALUE'] # cif总价
    # target_tab['totalfobvalue'] = exp_df['aaaaa'] # fob总价
    target_tab['grossweight']   = exp_df['ITEM_G_WEIGHT'] # 毛重
    target_tab['netweight']     = exp_df['ITEM_N_WEIGHT'] # 重量
    target_tab['quantity']      = exp_df['QUANTITY'] # 数量
    target_tab['quantityunit']  = exp_df['UNIT_OF_MEASURE'] # 数量单位
    # target_tab['teu'] = exp_df['aaaaa'] # TEU
    # target_tab['importer_forwarderagent'] = exp_df['aaaaa'] # 采购商货代公司标签
#     target_tab['supplier_forwarderagent'] = [0] * exp_df.shape[0] # 供应商货代公司标签
    target_tab['abnormaldata']            = [0] * exp_df.shape[0] # 是否命中异常数据规则
    # target_tab['portofloading'] = exp_df['aaaaa'] # 启运港
    # target_tab['portofdestination'] = exp_df['aaaaa'] # 目的港
    target_tab['loadingcountrycode'] = exp_df['EXPORT_COUNTRY'] # 启运国国际编码
    target_tab['loadingcountry']     = exp_df['EXPORT_COUNTRY'] # 启运国英文名称
    # target_tab['transportterm'] = exp_df['TRANS_TYPE'] # 运输方式
    # target_tab['tradeterm'] = exp_df['aaaaa'] # 成交方式
    # target_tab['paymentterm'] = exp_df['aaaaa'] # 付款方式
    # target_tab['carrier'] = exp_df['aaaaa'] # 承运人名称
    # target_tab['containerno'] = exp_df['aaaaa'] # 集装箱箱号
    target_tab['vesselname']    = exp_df['VESSEL_NAME'] # 船名
    # target_tab['brand'] = exp_df['aaaaa'] # 品牌
    target_tab['version'] = exp_df['version'] # 版本
    target_tab['country'] = exp_df['src_country'] # 国家
    # target_tab['IMPORTER_ID'] = exp_df['aaaaa'] # 渠道采购商编码
#     target_tab['SUPPLIER_ID'] = exp_df['EXPORTER_TAX_ID'] # 渠道供应商编码

    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签

    target_tab['cif_currency'] = 'TZA'                         # cif货币类型
    target_tab['fob_currency'] = 'TZA'                         # fob货币类型

    end=time.time()
    logger.info(f'Export data mapping and cleaning takes {round((end-start)/60,2)} minutes')
    return target_tab.loc[:,config.target_cols]


# 29
def UGA_get_target_import(imp_path, src_cols):
    """
    乌干达 进口
    29	非洲	UGANDA	乌干达	UGA
    """
    start = time.time()

    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    imp_df = pd.read_csv(imp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {imp_df.columns.values}')

    target_tab = pd.DataFrame(columns=config.target_cols)

    target_tab['channelno']          = ['zdzj'] * imp_df.shape[0]          # 渠道缩写
    target_tab['dataid']             = imp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = imp_df['iesign']                    # 进出口标志
    target_tab['datatype']           = ['D'] * imp_df.shape[0]             # 提单关单标志
    target_tab['writeoffflag']       = ['o'] * imp_df.shape[0]             # 冲销标志
    # target_tab['writeoffdataid']     = imp_df['aaaaa']                     # 冲销记录主键

    target_tab['outputdate'] = [
        f'{int(x[0]):04d}-{int(x[1]):02d}-{int(x[2]):02d}'
        for x in imp_df.loc[:, ['YEAR', 'MONTH', 'DAY']].values
    ]                                                                        # 日期

    # 需要转写为标准英文国名
    target_tab['origincountrycode']  = imp_df['ORIGN_COUNTRY']            # 原产国国际编码
    target_tab['origincountry']      = imp_df['ORIGN_COUNTRY']            # 原产国英文名称
    target_tab['countrycodeofdelivery'] = ['UGA'] * imp_df.shape[0] # 目的国国际编码
    target_tab['countryofdelivery'] = ['UGANDA'] * imp_df.shape[0] # 目的国英文名称

    target_tab['importername']       = imp_df['IMPORTER']                   # 采购商名称
    # target_tab['importeraddress']    = imp_df['aaaaa']                     # 采购商地址
    # target_tab['importercontact']    = imp_df['aaaaa']                     # 采购商联系方式
    target_tab['suppliername']       = imp_df['EXPORTER']                     # 供应商名称
    # target_tab['supplieraddress']    = imp_df['aaaaa']                     # 供应商地址
    # target_tab['suppliercontact']    = imp_df['aaaaa']                     # 供应商联系方式
    target_tab['hscode']             = imp_df['HS_CODE']                    # hs编码
    target_tab['hscodedescription']  = imp_df['HS_CODE_DESC']                     # hs编码描述
    target_tab['commoditydescription'] = [
        str(x).replace("\"", " ") if x is not None else x
        for x in imp_df['PRODUCT_DESC'].values
    ]                                                                        # 产品描述
    target_tab['totalcifvalue']      = imp_df['CIF_IN_USD']                 # cif总价
    # target_tab['totalfobvalue']      = imp_df['aaaaa']                      # fob总价
    target_tab['grossweight']        = imp_df['G_WEIGHT_IN_KG']             # 毛重
    # target_tab['netweight']          = imp_df['aaaaa']                     # 重量
    target_tab['quantity']           = imp_df['QUANTITY']                  # 数量
    target_tab['quantityunit']       = imp_df['UNIT_OF_QUANTITY']          # 数量单位
    # target_tab['teu']                = imp_df['aaaaa']                      # TEU
    target_tab['importer_forwarderagent'] = [0] * imp_df.shape[0]          # 采购商货代公司标签（需根据IMPORTER判断0/1）
    # target_tab['supplier_forwarderagent'] = imp_df['aaaaa']                # 供应商货代公司标签
    target_tab['abnormaldata']       = [0] * imp_df.shape[0]               # 是否命中异常数据规则（待判定）
    # target_tab['portofloading']      = imp_df['aaaaa']                      # 启运港
    # target_tab['portofdestination']  = imp_df['aaaaa']                      # 目的港
    target_tab['loadingcountrycode'] = imp_df['EXPORT_COUNTRY']             # 启运国国际编码（需转换为标准英文国名）
    target_tab['loadingcountry']     = imp_df['EXPORT_COUNTRY']             # 启运国英文名称（需转换为标准英文国名）
    # target_tab['transportterm']      = imp_df['aaaaa']                      # 运输方式（需映射成统一枚举值）
    # target_tab['tradeterm']          = imp_df['aaaaa']                      # 成交方式（需映射成统一枚举值）
    # target_tab['paymentterm']        = imp_df['aaaaa']                      # 付款方式
    # target_tab['carrier']            = imp_df['aaaaa']                      # 承运人名称
    # target_tab['containerno']        = imp_df['aaaaa']                      # 集装箱箱号
    # target_tab['vesselname']         = imp_df['aaaaa']                      # 船名
    # target_tab['brand']              = imp_df['aaaaa']                      # 品牌
    target_tab['version']            = imp_df['version']                      # 版本
    target_tab['country']            = imp_df['src_country']                      # 国家
    target_tab['IMPORTER_ID']        = imp_df['IMPORTER_ID']                # 渠道采购商编码
    # target_tab['SUPPLIER_ID']        = imp_df['aaaaa']                      # 渠道供应商编码

    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签

    target_tab['cif_currency'] = 'USD'                         # cif货币类型
    target_tab['fob_currency'] = 'USD'                         # fob货币类型

    end = time.time()
    logger.info(f'Import data mapping and cleaning takes {round((end-start)/60,2)} minutes')
    return target_tab.loc[:,config.target_cols]

def UGA_get_target_export(exp_path, src_cols):
    """
    乌干达 出口
    29	非洲	UGANDA	乌干达	UGA
    """
    start = time.time()
    
    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    exp_df = pd.read_csv(exp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {exp_df.columns.values}')

    target_tab = pd.DataFrame(columns=config.target_cols)

    target_tab['channelno']          = ['zdzj'] * exp_df.shape[0]          # 渠道缩写
    target_tab['dataid']             = exp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = exp_df['iesign']                    # 进出口标志
    target_tab['datatype']           = ['D'] * exp_df.shape[0]             # 提单关单标志
    target_tab['writeoffflag']       = ['o'] * exp_df.shape[0]             # 冲销标志
    # target_tab['writeoffdataid']     = exp_df['aaaaa']                     # 冲销记录主键

     # 只有当 YEAR、MONTH、DAY 都不为空时，才生成日期字符串
    target_tab['outputdate'] = [
        f'{int(x[0]):04d}-{int(x[1]):02d}-{int(x[2]):02d}' if pd.notna(x[0]) and pd.notna(x[1]) and pd.notna(x[2])
        else None
        for x in exp_df.loc[:, ['YEAR', 'MONTH', 'DAY']].values]

    # 原产来源国需要再确认，直接写死
    target_tab['origincountrycode']  = ['UGA'] * exp_df.shape[0]           # 原产国国际编码
    target_tab['origincountry']      = ['UGANDA'] * exp_df.shape[0]        # 原产国英文名称
    # 需转写为标准英文国名
    target_tab['countrycodeofdelivery'] = exp_df['DEST_COUNTRY']            # 目的国国际编码
    target_tab['countryofdelivery']  = exp_df['DEST_COUNTRY']              # 目的国英文名称（需转写为标准英文国名）

    target_tab['importername']       = exp_df['IMPORTER']                     # 采购商名称
    # target_tab['importeraddress']    = exp_df['aaaaa']                     # 采购商地址
    # target_tab['importercontact']    = exp_df['aaaaa']                     # 采购商联系方式
    target_tab['suppliername']       = exp_df['EXPORTER']                   # 供应商名称
    # target_tab['supplieraddress']    = exp_df['aaaaa']                     # 供应商地址
    # target_tab['suppliercontact']    = exp_df['aaaaa']                     # 供应商联系方式
    target_tab['hscode']             = exp_df['HS_CODE']                    # hs编码
    target_tab['hscodedescription']  = exp_df['HS_CODE_DESC']                     # hs编码描述
    target_tab['commoditydescription'] = [
        str(x).replace("\"", " ") if x is not None else x
        for x in exp_df['PRODUCT_DESC'].values
    ]                                                                        # 产品描述
    target_tab['totalcifvalue']      = exp_df['CIF_IN_USD']                 # cif总价
    # target_tab['totalfobvalue']      = exp_df['aaaaa']                      # fob总价
    target_tab['grossweight']        = exp_df['G_WEIGHT_IN_KG']             # 毛重
    # target_tab['netweight']          = exp_df['aaaaa']                     # 重量
    target_tab['quantity']           = exp_df['QUANTITY']                  # 数量
    target_tab['quantityunit']       = exp_df['UNIT_OF_QUANTITY']          # 数量单位
    # target_tab['teu']                = exp_df['aaaaa']                      # TEU
    # target_tab['importer_forwarderagent'] = exp_df['aaaaa']                # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = [0] * exp_df.shape[0]          # 供应商货代公司标签（需根据EXPORTER判断0/1）
    target_tab['abnormaldata']       = [0] * exp_df.shape[0]               # 是否命中异常数据规则（待判定）
    # target_tab['portofloading']      = exp_df['CUSTOMS']                   # 启运港
    # target_tab['portofdestination']  = exp_df['aaaaa']                      # 目的港
    target_tab['loadingcountrycode'] = exp_df['EXPORT_COUNTRY']             # 启运国国际编码（需转换为标准英文国名）
    target_tab['loadingcountry']     = exp_df['EXPORT_COUNTRY']             # 启运国英文名称（需转换为标准英文国名）
    # target_tab['transportterm']      = exp_df['TRANS_TYPE']                 # 运输方式（需映射成统一枚举值）
    # target_tab['tradeterm']          = exp_df['aaaaa']                      # 成交方式（需映射成统一枚举值）
    # target_tab['paymentterm']        = exp_df['aaaaa']                      # 付款方式
    # target_tab['carrier']            = exp_df['aaaaa']                      # 承运人名称
    # target_tab['containerno']        = exp_df['aaaaa']                      # 集装箱箱号
    # target_tab['vesselname']         = exp_df['aaaaa']                      # 船名
    # target_tab['brand']              = exp_df['aaaaa']                      # 品牌
    target_tab['version']            = exp_df['version']                      # 版本
    target_tab['country']            = exp_df['src_country']                      # 国家
    # target_tab['IMPORTER_ID']        = exp_df['aaaaa']                      # 渠道采购商编码
    # target_tab['SUPPLIER_ID']        = exp_df['EXPORT_ID']                  # 渠道供应商编码

    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签

    target_tab['cif_currency'] = 'USD'                         # cif货币类型
    target_tab['fob_currency'] = 'USD'                         # fob货币类型

    end = time.time()
    logger.info(f'Export data mapping and cleaning takes {round((end-start)/60,2)} minutes')
    return target_tab.loc[:,config.target_cols]


# 30
def UKR_get_target_import(imp_path, src_cols):
    """
    乌克兰 进口
    30	欧洲	UKRAINE	乌克兰	UKR
    """
    start = time.time()
    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    imp_df = pd.read_csv(imp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {imp_df.columns.values}')
    
    target_tab = pd.DataFrame(columns=config.target_cols)
    
    target_tab['channelno'] = ['zdzj'] * imp_df.shape[0]  # 渠道编号
    target_tab['dataid']             = imp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = imp_df['iesign']                    # 进出口标志
    target_tab['writeoffflag'] = ['o'] * imp_df.shape[0]  # 核销标志
    target_tab['datatype'] = ['D'] * imp_df.shape[0]  # 数据类型
    # ----------------------------------------------------
    target_tab['outputdate'] = pd.to_datetime(imp_df['REG_DATE'], format='mixed').dt.strftime('%Y-%m-%d').values  # 登记日期
    
    # 2. Origin country info
    # target_tab['origincountrycode'] = None
    target_tab['origincountry'] = imp_df['ORIGIN_COUNTRY']  # 原产地国家
    
    # 3. Delivery country info
    target_tab['countrycodeofdelivery'] = ['UKR'] * imp_df.shape[0] # 目的国国际编码
    target_tab['countryofdelivery'] = ['UKRAINE'] * imp_df.shape[0] # 目的国英文名称
    
    # 4. Importer info (name and address extraction)
    # Extract name from CONSIGNEE_NAME_ADDRESS (assuming format "Name\nAddress")
    target_tab['importername'] = imp_df['CONSIGNEE_NAME_ADDRESS'].str.split('\n').str[0].fillna(
        imp_df['CONTRACT_HOLDER_NAME'])  # 收货人名称/合同持有方名称
    # Extract address from CONSIGNEE_NAME_ADDRESS
    target_tab['importeraddress'] = imp_df['CONSIGNEE_NAME_ADDRESS'].str.split('\n').str[1:].str.join(', ')  # 收货人地址
    # target_tab['importercontact'] = None
    
    # 5. Supplier info
    target_tab['suppliername'] = imp_df['SHIPPER_NAME']  # 发货人名称
    # target_tab['supplieraddress'] = None
    # target_tab['suppliercontact'] = None
    
    # 6. Product information
    target_tab['hscode'] = imp_df['HS_CODE']  # HS 编码
    # target_tab['hscodedescription'] = None
    target_tab['commoditydescription'] = imp_df['PRODUCT_DESC']  # 产品描述
    
    # 7. Value and weights
    target_tab['totalcifvalue'] = imp_df['CUSTOMS_VALUE_USD']  # 海关价值（美元）
    target_tab['totalfobvalue'] = imp_df['INVOICE_VALUE_USD']  # 发票金额（美元）
    # target_tab['grossweight'] = None
    target_tab['netweight'] = imp_df['N_WEIGHT_IN_KG']  # 净重（千克）
    
    # 8. Quantity information
    # target_tab['quantity'] = imp_df['QUANTITY']  # 数量
    # target_tab['quantityunit'] = imp_df['UNIT_OF_QUANTITY']  # 数量单位
    
    # 9. Logistics info (mostly None)
    # target_tab['teu'] = None
    # target_tab['importer_forwarderagent'] = None
    # target_tab['supplier_forwarderagent'] = None
    # target_tab['abnormaldata'] = None
    # target_tab['portofloading'] = None
    target_tab['portofdestination'] = imp_df['PLACE_OF_DELIVERY']  # 交货地点

    # 10. Loading country info
    # target_tab['loadingcountrycode'] = None
    target_tab['loadingcountry'] = imp_df['DEPARTURE_COUNTRY']  # 离境国家
    
    # 11. Transport terms
    target_tab['transportterm'] = imp_df['TRANS_TYPE_AT_BORDER'].fillna(imp_df['TRANS_TYPE_WITHIN_COUNTRY'])  # 边境运输类型/境内运输类型
    target_tab['tradeterm'] = imp_df['INCOTERMS']  # 国际贸易术语
    # target_tab['paymentterm'] = None
    
    # 12. Shipping info (None)
    # target_tab['carrier'] = None
    # target_tab['containerno'] = None
    # target_tab['vesselname'] = None
    # target_tab['brand'] = None
    target_tab['version'] = imp_df['version']
    
    # 13. Country info (multiple possible sources)
    target_tab['country']            = imp_df['src_country']                      # 国家
    
    # 14. ID fields
#     target_tab['IMPORTER_ID'] = imp_df['CONSIGNEE_CODE']  # 收货人代码

    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签

    target_tab['cif_currency'] = 'USD'                         # cif货币类型
    target_tab['fob_currency'] = 'USD'                         # fob货币类型
    
    end = time.time()
    logger.info(f'Import data mapping and cleaning takes {round((end - start) / 60, 2)} minutes')
    
    return target_tab.loc[:,config.target_cols]

def UKR_get_target_export_Excel(exp_path, src_cols):
    """
    乌克兰 出口1
    30	欧洲	UKRAINE	乌克兰	UKR
    """
    start = time.time()
    
    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    exp_df = pd.read_csv(exp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {exp_df.columns.values}')
    
    target_tab = pd.DataFrame(columns=config.target_cols)
    
    target_tab['channelno'] = ['zdzj'] * exp_df.shape[0]  # 渠道编号
    target_tab['dataid']             = exp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = exp_df['iesign']                    # 进出口标志
    target_tab['writeoffflag'] = ['o'] * exp_df.shape[0]  # 核销标志
    target_tab['datatype'] = ['D'] * exp_df.shape[0]  # 数据类型
    # ----------------------------------------------------
    target_tab['outputdate'] = pd.to_datetime(exp_df['REG_DATE'], format='mixed').dt.strftime('%Y-%m-%d').values  # 登记日期
    
    # 2. Origin country info
    target_tab['origincountrycode'] = ['UKR']*exp_df.shape[0]                 # 原产国国际编码
    target_tab['origincountry'] = ['UKRAINE']*exp_df.shape[0]          # 原产国英文名称
    
    # 3. Delivery country info
    # target_tab['countrycodeofdelivery'] = None
    target_tab['countryofdelivery'] = exp_df['COUNTRY_OF_DESTINATION']  # 目的地国家
    
    # 4. Importer info
    target_tab['importername'] = exp_df['RECIPIENT_COMPANY_NAME'].fillna(exp_df['CONTRACT_HOLDER_COMPANY_NAME'])  # 接收方公司名称/合同持有公司名称
    target_tab['importeraddress'] = exp_df['DELIVERY_ADDRESS']  # 交付地址
    # target_tab['importercontact'] = None
    
    # 5. Supplier info
    target_tab['suppliername'] = exp_df['SENDER_COMPANY_NAME']  # 发送方公司名称
    # target_tab['supplieraddress'] = None
    # target_tab['suppliercontact'] = None
    
    # 6. Product information
    target_tab['hscode'] = exp_df['GOODS_HS_CODE']  # 货物 HS 编码
    # target_tab['hscodedescription'] = None
    target_tab['commoditydescription'] = exp_df['GOODS_NAME']  # 货物名称
    
    # 7. Value and weights
    target_tab['totalcifvalue'] = exp_df['CUSTOMS_VALUE_USD']  # 海关价值（美元/当地货币）
    target_tab['totalfobvalue'] = exp_df['INVOICE_VALUE_USD']  # 发票金额（美元/当地货币）
    target_tab['grossweight'] = exp_df['GROSS_WEIGHT_KG']  # 毛重（千克）
    target_tab['netweight'] = exp_df['NET_WEIGHT_KG']  # 净重（千克）
    
    # 8. Quantity information
    target_tab['quantity'] = exp_df['QUANTITY_IN_ADDITIONAL_UNIT_OF_MEASURE']  # 附加计量单位数量
    target_tab['quantityunit'] = exp_df['ADDITIONAL_UNIT_OF_MEASURE']  # 附加计量单位
    
    # 9. Logistics info
    # target_tab['teu'] = None
    # target_tab['importer_forwarderagent'] = None
    # target_tab['supplier_forwarderagent'] = None
    # target_tab['abnormaldata'] = None
    # target_tab['portofloading'] = None
    # target_tab['portofdestination'] = None
    
    # 10. Loading country info
    # target_tab['loadingcountrycode'] = None
    target_tab['loadingcountry'] = exp_df['COUNTRY OF SHIPPING']  # 装运国
    
    # 11. Transport terms
    target_tab['transportterm'] = exp_df['TRANSPORT_CODE_AT_BORDER'].fillna(
        exp_df['TRANSPORT_AT_BORDER'].fillna(exp_df['TRANSPORT_INSIDE_COUNTRY'])  # 边境运输方式代码/边境运输方式/境内运输方式
    )
    target_tab['tradeterm'] = exp_df['DELIVERY_TERMS_INCOTERMS']  # 交货术语（国际贸易术语）
    # target_tab['paymentterm'] = None
    
    # 12. Shipping info
    # target_tab['carrier'] = None
    target_tab['containerno'] = exp_df['CONTAINER_NUMBER']  # 集装箱编号
    # target_tab['vesselname'] = None
    # target_tab['brand'] = None
    target_tab['version'] = exp_df['version']
    
    # 13. Country info
    target_tab['country']            = exp_df['src_country']                      # 国家
    
    # 14. ID fields
#     target_tab['IMPORTER_ID'] = exp_df['REGISTRATION_CODE_OF_CONTRACT_HOLDER_COMPANY']  # 合同持有公司注册码
#     target_tab['SUPPLIER_ID'] = exp_df['REGISTRATION_CODE_OF_SENDER_COMPANY']  # 发送方公司注册码

    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签

    target_tab['cif_currency'] = 'USD'                         # cif货币类型
    target_tab['fob_currency'] = 'USD'                         # fob货币类型


    end = time.time()
    logger.info(f'Export data mapping and cleaning takes {round((end - start) / 60, 2)} minutes')
    
    return target_tab.loc[:,config.target_cols]

def UKR_get_target_export_Access(exp_path, src_cols):
    """
    乌克兰 出口2
    30	欧洲	UKRAINE	乌克兰	UKR
    """
    start = time.time()
    
    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    exp_df = pd.read_csv(exp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {exp_df.columns.values}')
    
    target_tab = pd.DataFrame(columns=config.target_cols)
    
    target_tab['channelno'] = ['zdzj'] * exp_df.shape[0]  # 渠道编号
    target_tab['dataid']             = exp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = exp_df['iesign']                    # 进出口标志
    target_tab['writeoffflag'] = ['o'] * exp_df.shape[0]  # 核销标志
    target_tab['datatype'] = ['D'] * exp_df.shape[0]  # 数据类型
    # ----------------------------------------------------
    # 1. Basic single-column mappings
    target_tab['outputdate'] = pd.to_datetime(exp_df['REG_DATE'], format='mixed').dt.strftime('%Y-%m-%d').values  # 登记日期
    
    # 2. Origin country info
    target_tab['origincountrycode'] = ['UKR']*exp_df.shape[0]                 # 原产国国际编码
    target_tab['origincountry'] = ['UKRAINE']*exp_df.shape[0]          # 原产国英文名称
    
    # 3. Delivery country info
    # target_tab['countrycodeofdelivery'] = None
    target_tab['countryofdelivery'] = exp_df['DEST_COUNTRY']  # 目的地国家
    
    # 4. Importer info (name and address extraction)
    # Extract name from CONSIGNEE_NAME_ADDRESS (assuming format "Name\nAddress")
    target_tab['importername'] = exp_df['CONSIGNEE_NAME_ADDRESS'].str.split('\n').str[0].fillna(
        exp_df['CONTRACT_HOLDER_NAME'])  # 收货人名称/合同持有方名称
    # Extract address from CONSIGNEE_NAME_ADDRESS
    target_tab['importeraddress'] = exp_df['CONSIGNEE_NAME_ADDRESS'].str.split('\n').str[1:].str.join(', ')  # 收货人地址
    # target_tab['importercontact'] = None
    
    # 5. Supplier info
    target_tab['suppliername'] = exp_df['SHIPPER_NAME']  # 发货人名称
    # target_tab['supplieraddress'] = None
    # target_tab['suppliercontact'] = None
    
    # 6. Product information
    target_tab['hscode'] = exp_df['HS_CODE']  # HS 编码
    # target_tab['hscodedescription'] = None
    target_tab['commoditydescription'] = exp_df['PRODUCT_DESC']  # 产品描述
    
    # 7. Value and weights
    target_tab['totalcifvalue'] = exp_df['CUSTOMS_VALUE_USD']  # 海关价值（美元）
    target_tab['totalfobvalue'] = exp_df['INVOICE_VALUE_USD']  # 发票金额（美元）
    # target_tab['grossweight'] = None
    target_tab['netweight'] = exp_df['N_WEIGHT_IN_KG']  # 净重（千克）
    
    # 8. Quantity information
    target_tab['quantity'] = exp_df['QTY']  # 数量
    target_tab['quantityunit'] = exp_df['UOM']  # 计量单位
    
    # 9. Logistics info
    # target_tab['teu'] = None
    # target_tab['importer_forwarderagent'] = None
    # target_tab['supplier_forwarderagent'] = None
    # target_tab['abnormaldata'] = None
    # target_tab['portofloading'] = None
    # target_tab['portofdestination'] = None
    
    # 10. Loading country info
    # target_tab['loadingcountrycode'] = None
    target_tab['loadingcountry'] = exp_df['DEPARTURE_COUNTRY']  # 离境国家
    
    # 11. Transport terms
    target_tab['transportterm'] = exp_df['TRANS_TYPE_AT_BORDER'].fillna(exp_df['TRANS_TYPE_WITHIN_COUNTRY'])  # 边境运输类型/境内运输类型
    target_tab['tradeterm'] = exp_df['INCOTERMS']  # 国际贸易术语
    # target_tab['paymentterm'] = None
    
    # 12. Shipping info
    # target_tab['carrier'] = None
    # target_tab['containerno'] = None
    # target_tab['vesselname'] = None
    # target_tab['brand'] = None
    target_tab['version'] = exp_df['version']
    
    # 13. Country info (multiple possible sources)
    target_tab['country']            = exp_df['src_country']                      # 国家
    
    # 14. ID fields
    # target_tab['IMPORTER_ID'] = None
    target_tab['SUPPLIER_ID'] = exp_df['SHIPPER_CODE']  # 发货人代码

    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签

    target_tab['cif_currency'] = 'USD'                         # cif货币类型
    target_tab['fob_currency'] = 'USD'                         # fob货币类型

    end = time.time()
    logger.info(f'Export data mapping and cleaning takes {round((end - start) / 60, 2)} minutes')

    return target_tab.loc[:,config.target_cols]


# 31
def URY_get_target_import(imp_path, src_cols):
    """
    乌拉圭 进口
    31	拉丁美洲	URUGUAY	乌拉圭	URY
    """
    start = time.time()
    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    imp_df = pd.read_csv(imp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {imp_df.columns.values}')

    target_tab = pd.DataFrame(columns=config.target_cols)

    target_tab['channelno'] = ['zdzj'] * imp_df.shape[0] # 渠道缩写
    # 为每条记录生成独立的UUID并去除横线
    target_tab['dataid']             = imp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = imp_df['iesign']                    # 进出口标志
    target_tab['datatype'] = ['D'] * imp_df.shape[0] # 提单关单标志
    target_tab['writeoffflag'] = ['o'] * imp_df.shape[0] # 冲销标志
    # target_tab['writeoffdataid'] = imp_df['aaaaa'] # 冲销记录主键（暂未获取到对应字段）
    target_tab['outputdate'] = pd.to_datetime(imp_df['REG_DATE'], format='mixed').dt.strftime('%Y-%m-%d').values # 日期
    # 需要转写为标准英文国名
    target_tab['origincountrycode'] = imp_df['ORIGIN_COUNTRY'] # 原产国国际编码
    target_tab['origincountry'] = imp_df['ORIGIN_COUNTRY'] # 原产国英文名称
    target_tab['countrycodeofdelivery'] = ['URY'] * imp_df.shape[0] # 目的国国际编码
    target_tab['countryofdelivery'] = ['URUGUAY'] * imp_df.shape[0] # 目的国英文名称

    target_tab['importername'] = imp_df['IMPORTER'] # 采购商名称
    # target_tab['importeraddress'] = imp_df['aaaaa'] # 采购商地址（暂未获取到对应字段）
    # target_tab['importercontact'] = imp_df['aaaaa'] # 采购商联系方式（暂未获取到对应字段）
    # target_tab['suppliername'] = imp_df['aaaaa'] # 供应商名称（暂未获取到对应字段）
    # target_tab['supplieraddress'] = imp_df['aaaaa'] # 供应商地址（暂未获取到对应字段）
    # target_tab['suppliercontact'] = imp_df['aaaaa'] # 供应商联系方式（暂未获取到对应字段）
    target_tab['hscode'] = imp_df['HS_CODE'] # hs编码
    # target_tab['hscodedescription'] = imp_df['HS_CODE_DESC'] # hs编码描述（已注释，待启用）
    target_tab['commoditydescription'] = [str(x).replace("\"", " ") if x is not None else x for x in
                                          imp_df['PRODUCT_DESC'].values] # 产品描述
    target_tab['totalcifvalue'] = imp_df['CIF'] # cif总价
    target_tab['totalfobvalue'] = imp_df['CIF'] - imp_df['FREIGHT'] # fob总价（CIF减去运费）
    target_tab['grossweight'] = imp_df['G_WEIGHT'] # 毛重
    target_tab['netweight'] = imp_df['N_WEIGHT'] # 净重
    target_tab['quantity'] = imp_df['QUANTITY'] # 数量
    target_tab['quantityunit'] = imp_df['UNIT_OF_QUANTITY'] # 数量单位
    # target_tab['teu'] = imp_df['aaaaa'] # TEU（暂未获取到对应字段）
#     target_tab['importer_forwarderagent'] = [0] * imp_df.shape[0] # 采购商货代公司标签（根据IMPORTER判断为0）
    # target_tab['supplier_forwarderagent'] = imp_df['aaaaa'] # 供应商货代公司标签（暂未获取到对应字段）

    # 待判定
    target_tab['abnormaldata'] = [0] * imp_df.shape[0] # 是否命中异常数据规则

    # target_tab['portofloading'] = imp_df['EXIT_PORT'] # 启运港
    target_tab['portofdestination'] = imp_df['CUSTOMS'] # 目的港
    # 国家需转换为标准英文国名
    # target_tab['loadingcountrycode'] = imp_df['ORIGIN_COUNTRY'] # 启运国国际编码
    # target_tab['loadingcountry'] = imp_df['ORIGIN_COUNTRY'] # 启运国英文名称    
    # 需映射成统一枚举值
    target_tab['transportterm'] = imp_df['TRANS_TYPE'] # 运输方式
    # 需映射成统一枚举值
    # target_tab['tradeterm'] = imp_df['INCOTERMS'] # 成交方式
    # target_tab['brand'] = imp_df['BRAND'] # 品牌
    # target_tab['paymentterm'] = imp_df['aaaaa'] # 付款方式（暂未获取到对应字段）
    # target_tab['carrier'] = imp_df['aaaaa'] # 承运人名称（暂未获取到对应字段）
    # target_tab['containerno'] = imp_df['aaaaa'] # 集装箱箱号（暂未获取到对应字段）
    # target_tab['vesselname'] = imp_df['aaaaa'] # 船名（暂未获取到对应字段）
    
    target_tab['version'] = imp_df['version'] # 版本
    target_tab['country'] = imp_df['src_country'] # 国家（暂未获取到对应字段）
    target_tab['IMPORTER_ID'] = imp_df['IMPORTER_ID'] # 渠道采购商编码
    # target_tab['SUPPLIER_ID'] = imp_df['aaaaa'] # 渠道供应商编码（暂未获取到对应字段）

    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签

    target_tab['cif_currency'] = 'USD'                         # cif货币类型
    target_tab['fob_currency'] = 'USD'                         # fob货币类型

    end = time.time()
    logger.info(f'Import data mapping and cleaning takes {round((end - start) / 60, 2)} minutes')

    return target_tab.loc[:,config.target_cols]

def URY_get_target_export(exp_path, src_cols):
    """
    乌拉圭 出口
    31	拉丁美洲	URUGUAY	乌拉圭	URY
    """
    start = time.time()
    
    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    exp_df = pd.read_csv(exp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {exp_df.columns.values}')

    target_tab = pd.DataFrame(columns=config.target_cols)

    target_tab['channelno'] = ['zdzj'] * exp_df.shape[0] # 渠道缩写
    # 为每条记录生成独立的UUID并去除横线
    target_tab['dataid']             = exp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = exp_df['iesign']                    # 进出口标志
    target_tab['datatype'] = ['D'] * exp_df.shape[0] # 提单关单标志
    target_tab['writeoffflag'] = ['o'] * exp_df.shape[0] # 冲销标志
    # target_tab['writeoffdataid'] = exp_df['aaaaa'] # 冲销记录主键（暂未获取到对应字段）
    target_tab['outputdate'] = pd.to_datetime(exp_df['REG_DATE'], format='mixed').dt.strftime('%Y-%m-%d').values # 日期
    # 原产来源国需要再确认
    target_tab['origincountrycode'] = ['URY']*exp_df.shape[0]                 # 原产国国际编码
    target_tab['origincountry'] = ['URUGUAY']*exp_df.shape[0]          # 原产国英文名称
    # 需要转写为标准英文国名
    target_tab['countrycodeofdelivery'] = exp_df['DEST_COUNTRY'] # 目的国国际编码
    target_tab['countryofdelivery'] = exp_df['DEST_COUNTRY'] # 目的国英文名称

    # target_tab['importername'] = exp_df['aaaaa'] # 采购商名称（暂未获取到对应字段）
    # target_tab['importeraddress'] = exp_df['aaaaa'] # 采购商地址（暂未获取到对应字段）
    # target_tab['importercontact'] = exp_df['aaaaa'] # 采购商联系方式（暂未获取到对应字段）
    target_tab['suppliername'] = exp_df['EXPORTER'] # 供应商名称
    # target_tab['supplieraddress'] = exp_df['aaaaa'] # 供应商地址（暂未获取到对应字段）
    # target_tab['suppliercontact'] = exp_df['aaaaa'] # 供应商联系方式（暂未获取到对应字段）
    target_tab['hscode'] = exp_df['HS_CODE'] # hs编码
    # target_tab['hscodedescription'] = exp_df['aaaaa'] # hs编码描述（暂未获取到对应字段）
    target_tab['commoditydescription'] = [str(x).replace("\"", " ") if x is not None else x for x in
                                          exp_df['PRODUCT_DESC'].values] # 产品描述
#     target_tab['totalcifvalue'] = exp_df['FOB'] # cif总价（取自FOB字段）
    target_tab['totalfobvalue'] = exp_df['FOB'] # fob总价
    target_tab['grossweight'] = exp_df['G_WEIGHT'] # 毛重
    target_tab['netweight'] = exp_df['N_WEIGHT'] # 净重
    target_tab['quantity'] = exp_df['QUANTITY'] # 数量
    target_tab['quantityunit'] = exp_df['UNIT_OF_QUANTITY'] # 数量单位
    # target_tab['teu'] = exp_df['aaaaa'] # TEU（暂未获取到对应字段）
    # target_tab['importer_forwarderagent'] = exp_df['aaaaa'] # 采购商货代公司标签（暂未获取到对应字段）
#     target_tab['supplier_forwarderagent'] = [0] * exp_df.shape[0] # 供应商货代公司标签（根据EXPORTER判断为0）

    # 待判定
    target_tab['abnormaldata'] = [0] * exp_df.shape[0] # 是否命中异常数据规则

    # target_tab['portofloading'] = exp_df['CUSTOMS'] # 启运港
    # target_tab['portofdestination'] = exp_df['aaaaa'] # 目的港（暂未获取到对应字段）
    # 国家需转换为标准英文国名
    target_tab['loadingcountrycode'] = ['URY'] * exp_df.shape[0] # 启运国国际编码（默认URY）
    target_tab['loadingcountry'] = ['URUGUAY'] * exp_df.shape[0] # 启运国英文名称（默认URUGUAY）

    # 需映射成统一枚举值
    # target_tab['transportterm'] = exp_df['TRANS_TYPE'] # 运输方式（已注释，待映射）
    # 需映射成统一枚举值
    # target_tab['tradeterm'] = exp_df['INCOTERMS'] # 成交方式
    # target_tab['brand'] = exp_df['BRAND'] # 品牌
    # target_tab['paymentterm'] = exp_df['aaaaa'] # 付款方式（暂未获取到对应字段）
    # target_tab['carrier'] = exp_df['aaaaa'] # 承运人名称（暂未获取到对应字段）
    # target_tab['containerno'] = exp_df['aaaaa'] # 集装箱箱号（暂未获取到对应字段）
    # target_tab['vesselname'] = exp_df['aaaaa'] # 船名（暂未获取到对应字段）

    target_tab['version'] = exp_df['version'] # 版本
    target_tab['country'] = exp_df['src_country'] # 国家（暂未获取到对应字段）
    # target_tab['IMPORTER_ID'] = exp_df['aaaaa'] # 渠道采购商编码（暂未获取到对应字段）
    # target_tab['SUPPLIER_ID'] = exp_df['EXPORT_ID'] # 渠道供应商编码

    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签

    target_tab['cif_currency'] = 'USD'                         # cif货币类型
    target_tab['fob_currency'] = 'USD'                         # fob货币类型

    end = time.time()
    logger.info(f'Export data mapping and cleaning takes {round((end - start) / 60, 2)} minutes')

    return target_tab.loc[:,config.target_cols]


# 32
def UZB_get_target_import(imp_path, src_cols):
    """
    乌兹别克斯坦 进口
    32	亚洲	UZBEKISTAN	乌兹别克斯坦	UZB
    """
    start = time.time()

    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    imp_df = pd.read_csv(imp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {imp_df.columns.values}')

    target_tab = pd.DataFrame(columns=config.target_cols)

    target_tab['channelno']          = ['zdzj'] * imp_df.shape[0]          # 渠道缩写
    target_tab['dataid']             = imp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = imp_df['iesign']                    # 进出口标志
    target_tab['datatype']           = ['D'] * imp_df.shape[0]             # 提单关单标志
    target_tab['writeoffflag']       = ['o'] * imp_df.shape[0]             # 冲销标志
    # target_tab['writeoffdataid']     = imp_df['aaaaa']                     # 冲销记录主键

    target_tab['outputdate']         = pd.to_datetime(imp_df['REG_DATE'], format='mixed').dt.strftime('%Y-%m-%d').values                  # 日期
    target_tab['origincountrycode']  = imp_df['ORIGIN_COUNTRY']            # 原产国国际编码
    target_tab['origincountry']      = imp_df['ORIGIN_COUNTRY']            # 原产国英文名称
    target_tab['countrycodeofdelivery'] = ['UZB'] * imp_df.shape[0] # 目的国国际编码
    target_tab['countryofdelivery'] = ['UZBEKISTAN'] * imp_df.shape[0] # 目的国英文名称
    target_tab['importername']       = imp_df['CONSIGNEE_NAME']            # 采购商名称
#     target_tab['importeraddress']    = imp_df['CONSIGNEE_NAME']            # 采购商地址
    # target_tab['importercontact']    = imp_df['aaaaa']                     # 采购商联系方式
    target_tab['suppliername']       = imp_df['SHIPPER_NAME']                     # 供应商名称
    # target_tab['supplieraddress']    = imp_df['aaaaa']                     # 供应商地址
    # target_tab['suppliercontact']    = imp_df['aaaaa']                     # 供应商联系方式
    target_tab['hscode']             = imp_df['HS_CODE']                   # hs编码
    # target_tab['hscodedescription']  = imp_df['aaaaa']                     # hs编码描述
    target_tab['commoditydescription'] = [
        str(x).replace("\"", " ") if x is not None else x
        for x in imp_df['PRODUCT_DESC'].values
    ]                                                                        # 产品描述
    target_tab['totalcifvalue']      = imp_df['CUSTOMS_VALUE_USD']           # cif总价
#     target_tab['totalfobvalue']      = imp_df['CUSTOMS_VALUE_USD']         # fob总价
    # target_tab['grossweight']        = imp_df['aaaaa']                     # 毛重
    target_tab['netweight']          = imp_df['N_WEIGHT']                  # 重量
    target_tab['quantity']           = imp_df['QUANTITY']                  # 数量
    target_tab['quantityunit']       = imp_df['UNIT_OF_QUANTITY']          # 数量单位
    # target_tab['teu']                = imp_df['aaaaa']                     # TEU
#     target_tab['importer_forwarderagent'] = [0] * imp_df.shape[0]          # 采购商货代公司标签
    # target_tab['supplier_forwarderagent'] = imp_df['aaaaa']                # 供应商货代公司标签
    target_tab['abnormaldata']       = [0] * imp_df.shape[0]               # 是否命中异常数据规则
    # target_tab['portofloading']      = imp_df['aaaaa']                     # 启运港
    # target_tab['portofdestination']  = imp_df['aaaaa']                     # 目的港
    target_tab['loadingcountrycode'] = imp_df['DEPARTURE_COUNTRY']          # 启运国国际编码
    target_tab['loadingcountry']     = imp_df['DEPARTURE_COUNTRY']          # 启运国英文名称
    # target_tab['transportterm']      = imp_df['aaaaa']                      # 运输方式（需映射成统一枚举值）
    target_tab['tradeterm']          = imp_df['DELIVER_CONDITION_LETTER_CODE']  # 成交方式（需映射成统一枚举值）
    # target_tab['paymentterm']        = imp_df['aaaaa']                     # 付款方式
    # target_tab['carrier']            = imp_df['aaaaa']                     # 承运人名称
    # target_tab['containerno']        = imp_df['aaaaa']                     # 集装箱箱号
    # target_tab['vesselname']         = imp_df['aaaaa']                     # 船名
    # target_tab['brand']              = imp_df['aaaaa']                     # 品牌
    target_tab['version']            = imp_df['version']                     # 版本
    target_tab['country']            = imp_df['src_country']                     # 国家
#     target_tab['IMPORTER_ID']        = imp_df['CONSIGNEE_CODE']             # 渠道采购商编码
    # target_tab['SUPPLIER_ID']        = imp_df['aaaaa']                     # 渠道供应商编码

    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签

    target_tab['cif_currency'] = 'USD'                         # cif货币类型
    target_tab['fob_currency'] = 'USD'                         # fob货币类型

    end = time.time()
    logger.info(f'Import data mapping and cleaning takes {round((end-start)/60,2)} minutes')
    return target_tab.loc[:,config.target_cols]

def UZB_get_target_export(exp_path, src_cols):
    """
    乌兹别克斯坦 出口
    32	亚洲	UZBEKISTAN	乌兹别克斯坦	UZB
    """
    start = time.time()

    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    exp_df = pd.read_csv(exp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {exp_df.columns.values}')

    target_tab = pd.DataFrame(columns=config.target_cols)

    target_tab['channelno']          = ['zdzj'] * exp_df.shape[0]          # 渠道缩写
    target_tab['dataid']             = exp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = exp_df['iesign']                    # 进出口标志
    target_tab['datatype']           = ['D'] * exp_df.shape[0]             # 提单关单标志
    target_tab['writeoffflag']       = ['o'] * exp_df.shape[0]             # 冲销标志
    # target_tab['writeoffdataid']     = exp_df['aaaaa']                     # 冲销记录主键

    target_tab['outputdate']         = pd.to_datetime(exp_df['REG_DATE'], format='mixed').dt.strftime('%Y-%m-%d').values                  # 日期
    target_tab['origincountrycode'] = ['UZB']*exp_df.shape[0]                 # 原产国国际编码
    target_tab['origincountry'] = ['UZBEKISTAN']*exp_df.shape[0]          # 原产国英文名称
    target_tab['countrycodeofdelivery'] = exp_df['DEST_COUNTRY']           # 目的国国际编码（需转写为标准英文国名）
    target_tab['countryofdelivery']  = exp_df['DEST_COUNTRY']             # 目的国英文名称（需转写为标准英文国名）
    target_tab['importername']       = exp_df['CONSIGNEE_NAME']                     # 采购商名称
    # target_tab['importeraddress']    = exp_df['aaaaa']                     # 采购商地址
    # target_tab['importercontact']    = exp_df['aaaaa']                     # 采购商联系方式
    target_tab['suppliername']       = exp_df['SHIPPER_NAME']              # 供应商名称
    # target_tab['supplieraddress']    = exp_df['aaaaa']                     # 供应商地址
    # target_tab['suppliercontact']    = exp_df['aaaaa']                     # 供应商联系方式
    target_tab['hscode']             = exp_df['HS_CODE']                   # hs编码
    # target_tab['hscodedescription']  = exp_df['aaaaa']                     # hs编码描述
    target_tab['commoditydescription'] = [
        str(x).replace("\"", " ") if x is not None else x
        for x in exp_df['PRODUCT_DESC'].values
    ]                                                                        # 产品描述
    target_tab['totalcifvalue']      = exp_df['CUSTOMS_VALUE_USD']           # cif总价
#     target_tab['totalfobvalue']      = exp_df['CUSTOMS_VALUE_USD']         # fob总价
    # target_tab['grossweight']        = exp_df['aaaaa']                     # 毛重
    target_tab['netweight']          = exp_df['N_WEIGHT']                  # 重量
    target_tab['quantity']           = exp_df['QUANTITY']                  # 数量
    target_tab['quantityunit']       = exp_df['UNIT_OF_QUANTITY']          # 数量单位
    # target_tab['teu']                = exp_df['aaaaa']                     # TEU
    # target_tab['importer_forwarderagent'] = exp_df['aaaaa']                # 采购商货代公司标签
#     target_tab['supplier_forwarderagent'] = [0] * exp_df.shape[0]          # 供应商货代公司标签（需根据SHIPPER_NAME判断0/1）
    target_tab['abnormaldata']       = [0] * exp_df.shape[0]               # 是否命中异常数据规则（待判定）
    # target_tab['portofloading']      = exp_df['aaaaa']                     # 启运港
    # target_tab['portofdestination']  = exp_df['aaaaa']                     # 目的港
    target_tab['loadingcountrycode'] = ['UZB'] * exp_df.shape[0]           # 启运国国际编码（需转换为标准英文国名）
    target_tab['loadingcountry']     = ['UZBEKISTAN'] * exp_df.shape[0]    # 启运国英文名称（需转换为标准英文国名）
    # target_tab['transportterm']      = exp_df['aaaaa']                     # 运输方式（需映射成统一枚举值）
    target_tab['tradeterm']          = exp_df['DELIVER_CONDITION_LETTER_CODE']  # 成交方式（需映射成统一枚举值）
    # target_tab['paymentterm']        = exp_df['aaaaa']                     # 付款方式
    # target_tab['carrier']            = exp_df['aaaaa']                     # 承运人名称
    # target_tab['containerno']        = exp_df['aaaaa']                     # 集装箱箱号
    # target_tab['vesselname']         = exp_df['aaaaa']                     # 船名
    # target_tab['brand']              = exp_df['aaaaa']                     # 品牌
    target_tab['version']            = exp_df['version']                     # 版本
    target_tab['country']            = exp_df['src_country']                     # 国家
    # target_tab['IMPORTER_ID']        = exp_df['aaaaa']                     # 渠道采购商编码
#     target_tab['SUPPLIER_ID']        = exp_df['SHIPPER_CODE']              # 渠道供应商编码

    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签

    target_tab['cif_currency'] = 'USD'                         # cif货币类型
    target_tab['fob_currency'] = 'USD'                         # fob货币类型

    end = time.time()
    logger.info(f'Export data mapping and cleaning takes {round((end-start)/60,2)} minutes')
    return target_tab.loc[:,config.target_cols]


# 33
def IND_get_target_import(imp_path, src_cols):
    """
    印度 进口
    33  亚洲  INDIA   印度  IND
    """
    start = time.time()
    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    imp_df = pd.read_csv(imp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {imp_df.columns.values}')

    target_tab = pd.DataFrame(columns=config.target_cols)

    target_tab['channelno'] = ['zdzj'] * imp_df.shape[0] # 渠道缩写
    target_tab['dataid']             = imp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = imp_df['iesign']                    # 进出口标志
    target_tab['datatype'] = ['D'] * imp_df.shape[0] # 提单关单标志
    target_tab['writeoffflag'] = ['o'] * imp_df.shape[0] # 冲销标志
    # target_tab['writeoffdataid'] = imp_df['aaa'] # 冲销记录主键
    target_tab['outputdate'] = pd.to_datetime(imp_df['REG_DATE'], format='mixed').dt.strftime('%Y-%m-%d').values # 日期
    target_tab['origincountrycode'] = imp_df['ORIGIN_COUNTRY'] # 原产国国际编码
    target_tab['origincountry'] = imp_df['ORIGIN_COUNTRY'] # 原产国英文名称
    target_tab['countrycodeofdelivery'] = ['IND'] * imp_df.shape[0] # 目的国国际编码
    target_tab['countryofdelivery'] = ['INDIA'] * imp_df.shape[0] # 目的国英文名称
    target_tab['importername'] = imp_df['IMPORTER_NAME'] # 采购商名称
    target_tab['importeraddress'] = imp_df['IMPORTER_ADDRESS'] # 采购商地址
    # target_tab['importercontact'] = imp_df['aaaaa'] # 采购商联系方式
    target_tab['suppliername'] = imp_df['EXPORTER_NAME'] # 供应商名称
    # target_tab['supplieraddress'] = imp_df['aaaaa'] # 供应商地址
    # target_tab['suppliercontact'] = imp_df['aaaaa'] # 供应商联系方式
    target_tab['hscode'] = imp_df['HS_CODE'] # hs编码
    # target_tab['hscodedescription'] = imp_df['aaaaa'] # hs编码描述
    target_tab['commoditydescription'] = [str(x).replace("\"", " ") if x is not None else x for x in
                                          imp_df['PRODUCT_DESC'].values] # 产品描述
    target_tab['totalcifvalue'] = imp_df['TOTAL_VALUE_USD'] # cif总价
    target_tab['totalfobvalue'] = imp_df['TOTAL_VALUE_USD'] # fob总价
    # target_tab['grossweight'] = imp_df['G_WEIGHT'] # 毛重
    # target_tab['netweight'] = imp_df['N_WEIGHT'] # 重量
    target_tab['quantity'] = imp_df['QUANTITY'] # 数量
    target_tab['quantityunit'] = imp_df['UNIT_OF_QUANTITY'] # 数量单位
    # target_tab['teu'] = imp_df['aaaaa'] # TEU
    # 需要判断根据imp_df['IMPORTER']判断是否为0/1
#     target_tab['importer_forwarderagent'] = [0] * imp_df.shape[0] # 采购商货代公司标签
    # target_tab['supplier_forwarderagent'] = imp_df['aaaaa'] # 供应商货代公司标签
    # 待判定
    target_tab['abnormaldata'] = [0] * imp_df.shape[0] # 是否命中异常数据规则
    # target_tab['portofloading'] = imp_df['ORIGIN_PORT'] # 启运港
    target_tab['portofdestination'] = imp_df['INDIAN_PORT'] # 目的港
    # 国家需转换为标准英文国名
    target_tab['loadingcountrycode'] = imp_df['ORIGIN_COUNTRY'] # 启运国国际编码
    target_tab['loadingcountry'] = imp_df['ORIGIN_COUNTRY'] # 启运国英文名称
    # 需映射成统一枚举值
    target_tab['transportterm'] = imp_df['TRANS_TYPE'] # 运输方式
    # target_tab['tradeterm'] = imp_df['INCOTERMS'] # 成交方式
    # target_tab['paymentterm'] = imp_df['aaaaa'] # 付款方式
    # target_tab['carrier'] = imp_df['aaaaa'] # 承运人名称
    # target_tab['containerno'] = imp_df['aaaaa'] # 集装箱箱号
    # target_tab['vesselname'] = imp_df['aaaaa'] # 船名
    # target_tab['brand'] = imp_df['aaaaa'] # 品牌
    target_tab['version'] = imp_df['version'] # 版本
    target_tab['country'] = imp_df['src_country'] # 国家
    target_tab['IMPORTER_ID'] = imp_df['IMPORTER_ID'] # 渠道采购商编码
    # target_tab['SUPPLIER_ID'] = imp_df['aaaaa'] # 渠道供应商编码

    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签

    target_tab['cif_currency'] = 'USD'                         # cif货币类型
    target_tab['fob_currency'] = 'USD'                         # fob货币类型

    end = time.time()
    logger.info(f'Import data mapping and cleaning takes {round((end - start) / 60, 2)} minutes')

    return target_tab.loc[:,config.target_cols]

def IND_get_target_export(exp_path, src_cols):
    """
    印度 出口
    33  亚洲  INDIA   印度  IND
    """
    start = time.time()

    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    exp_df = pd.read_csv(exp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {exp_df.columns.values}')

    target_tab = pd.DataFrame(columns=config.target_cols)

    target_tab['channelno'] = ['zdzj'] * exp_df.shape[0] # 渠道缩写
    target_tab['dataid']             = exp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = exp_df['iesign']                    # 进出口标志
    target_tab['datatype'] = ['D'] * exp_df.shape[0] # 提单关单标志
    target_tab['writeoffflag'] = ['o'] * exp_df.shape[0] # 冲销标志
    # target_tab['writeoffdataid'] = exp_df['aaa'] # 冲销记录主键
    target_tab['outputdate'] = pd.to_datetime(exp_df['REG_DATE'], format='mixed').dt.strftime('%Y-%m-%d').values # 日期
    target_tab['origincountrycode'] = ['IND']*exp_df.shape[0]                 # 原产国国际编码
    target_tab['origincountry'] = ['INDIA']*exp_df.shape[0]          # 原产国英文名称
    # 需要转写为标准英文国名
    target_tab['countrycodeofdelivery'] = exp_df['DEST_COUNTRY'] # 目的国国际编码
    target_tab['countryofdelivery'] = exp_df['DEST_COUNTRY'] # 目的国英文名称
    target_tab['importername'] = exp_df['IMPORTER_NAME'] # 采购商名称
    # target_tab['importeraddress'] = exp_df['aaaaa'] # 采购商地址
    # target_tab['importercontact'] = exp_df['aaaaa'] # 采购商联系方式
    target_tab['suppliername'] = exp_df['EXPORTER_NAME'] # 供应商名称
    # target_tab['supplieraddress'] = exp_df['aaaaa'] # 供应商地址
    # target_tab['suppliercontact'] = exp_df['aaaaa'] # 供应商联系方式
    target_tab['hscode'] = exp_df['HS_CODE'] # hs编码
    # target_tab['hscodedescription'] = exp_df['aaaaa'] # hs编码描述
    target_tab['commoditydescription'] = [str(x).replace("\"", " ") if x is not None else x for x in
                                          exp_df['PRODUCT_DESC'].values] # 产品描述
#     target_tab['totalcifvalue'] = exp_df['TOTAL_FOB_IN_FC'] # cif总价
    # target_tab['totalfobvalue'] = exp_df['TOTAL_FOB_IN_FC'] # fob总价
    target_tab['totalfobvalue'] = exp_df['TOTAL_FOB_IN_INR'] # fob总价
    
    # target_tab['grossweight'] = exp_df['G_WEIGHT'] # 毛重
    # target_tab['netweight'] = exp_df['N_WEIGHT'] # 重量
    target_tab['quantity'] = exp_df['QUANTITY'] # 数量
    target_tab['quantityunit'] = exp_df['UNIT_OF_QUANTITY'] # 数量单位
    # target_tab['teu'] = exp_df['aaaaa'] # TEU
#     target_tab['importer_forwarderagent'] = '0' # 采购商货代公司标签
    # 需要判断根据imp_df['EXPORTER']判断是否为0/1
    target_tab['supplier_forwarderagent'] = [0] * exp_df.shape[0] # 供应商货代公司标签
    # 待判定
    target_tab['abnormaldata'] = [0] * exp_df.shape[0] # 是否命中异常数据规则
    target_tab['portofloading'] = exp_df['INDIAN_PORT_NAME'] # 启运港
    target_tab['portofdestination'] = exp_df['DEST_PORT'] # 目的港
    # 国家需转换为标准英文国名
    target_tab['loadingcountrycode'] = ['IND'] * exp_df.shape[0] # 启运国国际编码
    target_tab['loadingcountry'] = ['INDIA'] * exp_df.shape[0] # 启运国英文名称
    # 需映射成统一枚举值
    target_tab['transportterm'] = exp_df['TRANS_TYPE'] # 运输方式
    # target_tab['tradeterm'] = exp_df['INCOTERMS'] # 成交方式
    # target_tab['paymentterm'] = exp_df['aaaaa'] # 付款方式
    # target_tab['carrier'] = exp_df['aaaaa'] # 承运人名称
    # target_tab['containerno'] = exp_df['aaaaa'] # 集装箱箱号
    # target_tab['vesselname'] = exp_df['aaaaa'] # 船名
    # target_tab['brand'] = exp_df['aaaaa'] # 品牌
    target_tab['version'] = exp_df['version'] # 版本
    target_tab['country'] = exp_df['src_country'] # 国家
    # target_tab['IMPORTER_ID'] = exp_df['aaaaa'] # 渠道采购商编码
    # target_tab['SUPPLIER_ID'] = exp_df['aaaaa'] # 渠道供应商编码

    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签

#     target_tab['cif_currency'] = exp_df['FOREIGN_CURRENCY']                       # cif货币类型
    target_tab['fob_currency'] = 'IND'                         # fob货币类型

    end = time.time()
    logger.info(f'Export data mapping and cleaning takes {round((end - start) / 60, 2)} minutes')

    return target_tab.loc[:,config.target_cols]


# 34
def GBR_get_target_import(imp_path, src_cols):
    """
    英国 进口
    34	欧洲	UNITED KINGDOM	英国	GBR
    """
    start = time.time()

    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    imp_df = pd.read_csv(imp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {imp_df.columns.values}')

    target_tab = pd.DataFrame(columns=config.target_cols)

    target_tab['channelno']          = ['zdzj'] * imp_df.shape[0]          # 渠道缩写
    target_tab['dataid']             = imp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = imp_df['iesign']                    # 进出口标志
    target_tab['datatype']           = ['L'] * imp_df.shape[0]             # 提单关单标志
    target_tab['writeoffflag']       = ['o'] * imp_df.shape[0]             # 冲销标志
    # target_tab['writeoffdataid']     = imp_df['aaaaa']                     # 冲销记录主键

    target_tab['outputdate'] = [
        f'{int(x[0]):04d}-{int(x[1]):02d}-01'
        for x in imp_df.loc[:, ['YEAR', 'MONTH']].values
    ]                                                                        # 日期

    # 进口无原产国/启运国信息，置空
    # target_tab['origincountrycode']  = imp_df['aaaaa']                      # 原产国国际编码
    # target_tab['origincountry']      = imp_df['aaaaa']                      # 原产国英文名称
    target_tab['countrycodeofdelivery'] = ['GBR'] * imp_df.shape[0]         # 目的国国际编码
    target_tab['countryofdelivery']  = ['UNITED KINGDOM'] * imp_df.shape[0] # 目的国英文名称

    target_tab['importername']       = imp_df['IMPORTER']                   # 采购商名称
    target_tab['importeraddress']    = imp_df['ADDRESS']                    # 采购商地址
    # target_tab['importercontact']    = imp_df['aaaaa']                      # 采购商联系方式
    # target_tab['suppliername']       = imp_df['aaaaa']                      # 供应商名称
    # target_tab['supplieraddress']    = imp_df['aaaaa']                      # 供应商地址
    # target_tab['suppliercontact']    = imp_df['aaaaa']                      # 供应商联系方式
    target_tab['hscode']             = imp_df['HS_CODE']                    # hs编码
    target_tab['hscodedescription']  = imp_df['HS_CODE_DESC']               # hs编码描述
    # target_tab['commoditydescription'] = imp_df['aaaaa']                    # 产品描述
    # target_tab['totalcifvalue']      = imp_df['aaaaa']                      # cif总价
    # target_tab['totalfobvalue']      = imp_df['aaaaa']                      # fob总价
    # target_tab['grossweight']        = imp_df['aaaaa']                      # 毛重
    # target_tab['netweight']          = imp_df['aaaaa']                      # 重量
    # target_tab['quantity']           = imp_df['aaaaa']                      # 数量
    # target_tab['quantityunit']       = imp_df['aaaaa']                      # 数量单位
    # target_tab['teu']                = imp_df['aaaaa']                      # TEU
    target_tab['importer_forwarderagent'] = [0] * imp_df.shape[0]          # 采购商货代公司标签
    # target_tab['supplier_forwarderagent'] = imp_df['aaaaa']                 # 供应商货代公司标签
    target_tab['abnormaldata']       = [0] * imp_df.shape[0]               # 是否命中异常数据规则
    # target_tab['portofloading']      = imp_df['aaaaa']                      # 启运港
    # target_tab['portofdestination']  = imp_df['aaaaa']                      # 目的港
    # target_tab['loadingcountrycode'] = imp_df['aaaaa']                      # 启运国国际编码
    # target_tab['loadingcountry']     = imp_df['aaaaa']                      # 启运国英文名称
    # target_tab['transportterm']      = imp_df['aaaaa']                      # 运输方式（无运输及成交方式）
    # target_tab['tradeterm']          = imp_df['aaaaa']                      # 成交方式
    # target_tab['paymentterm']        = imp_df['aaaaa']                      # 付款方式
    # target_tab['carrier']            = imp_df['aaaaa']                      # 承运人名称
    # target_tab['containerno']        = imp_df['aaaaa']                      # 集装箱箱号
    # target_tab['vesselname']         = imp_df['aaaaa']                      # 船名
    # target_tab['brand']              = imp_df['aaaaa']                      # 品牌
    target_tab['version']            = imp_df['version']                      # 版本
    target_tab['country']            = imp_df['src_country']                      # 国家
    target_tab['IMPORTER_ID']        = imp_df['IMPORTER']                   # 渠道采购商编码
    # target_tab['SUPPLIER_ID']        = imp_df['aaaaa']                      # 渠道供应商编码

    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签

    target_tab['cif_currency'] = 'USD'                         # cif货币类型
    target_tab['fob_currency'] = 'USD'                         # fob货币类型

    end = time.time()
    logger.info(f'Import data mapping and cleaning takes {round((end-start)/60,2)} minutes')
    return target_tab.loc[:,config.target_cols]

def GBR_get_target_export(exp_path, src_cols):
    """
    英国 出口
    34	欧洲	UNITED KINGDOM	英国	GBR
    """
    start = time.time()

    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    exp_df = pd.read_csv(exp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {exp_df.columns.values}')

    target_tab = pd.DataFrame(columns=config.target_cols)

    target_tab['channelno']          = ['zdzj'] * exp_df.shape[0]          # 渠道缩写
    target_tab['dataid']             = exp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = exp_df['iesign']                    # 进出口标志
    target_tab['datatype']           = ['L'] * exp_df.shape[0]             # 提单关单标志
    target_tab['writeoffflag']       = ['o'] * exp_df.shape[0]             # 冲销标志
    # target_tab['writeoffdataid']     = exp_df['aaaaa']                     # 冲销记录主键

    target_tab['outputdate'] = [
        f'{int(x[0]):04d}-{int(x[1]):02d}-01'
        for x in exp_df.loc[:, ['YEAR', 'MONTH']].values
    ]                                                                        # 日期

    target_tab['origincountrycode'] = ['GBR']*exp_df.shape[0]                 # 原产国国际编码
    target_tab['origincountry'] = ['UNITED KINGDOM']*exp_df.shape[0]          # 原产国英文名称
    # target_tab['countrycodeofdelivery'] = exp_df['aaaaa']                   # 目的国国际编码（无目的国信息）
    # target_tab['countryofdelivery']  = exp_df['aaaaa']                      # 目的国英文名称（无目的国信息）

    # target_tab['importername']       = exp_df['aaaaa']                      # 采购商名称
    # target_tab['importeraddress']    = exp_df['aaaaa']                      # 采购商地址
    # target_tab['importercontact']    = exp_df['aaaaa']                      # 采购商联系方式
    target_tab['suppliername']       = exp_df['EXPORTER']                      # 供应商名称
    # target_tab['supplieraddress']    = exp_df['aaaaa']                      # 供应商地址
    # target_tab['suppliercontact']    = exp_df['aaaaa']                      # 供应商联系方式
    target_tab['hscode']             = exp_df['HS_CODE']                    # hs编码
    target_tab['hscodedescription']  = exp_df['HS_CODE_DESC']               # hs编码描述
    # target_tab['commoditydescription'] = exp_df['aaaaa']                    # 产品描述（无产品描述）
    # target_tab['totalcifvalue']      = exp_df['aaaaa']                      # cif总价（无金额、重量、数量，置空）
    # target_tab['totalfobvalue']      = exp_df['aaaaa']                      # fob总价（无金额、重量、数量，置空）
    # target_tab['grossweight']        = exp_df['aaaaa']                      # 毛重（无金额、重量、数量，置空）
    # target_tab['netweight']          = exp_df['aaaaa']                      # 重量（无金额、重量、数量，置空）
    # target_tab['quantity']           = exp_df['aaaaa']                      # 数量（无金额、重量、数量，置空）
    # target_tab['quantityunit']       = exp_df['aaaaa']                      # 数量单位（无金额、重量、数量，置空）
    # target_tab['teu']                = exp_df['aaaaa']                      # TEU
    # target_tab['importer_forwarderagent'] = exp_df['aaaaa']                 # 采购商货代公司标签
#     target_tab['supplier_forwarderagent'] = [0] * exp_df.shape[0]          # 供应商货代公司标签
    target_tab['abnormaldata']       = [0] * exp_df.shape[0]               # 是否命中异常数据规则（待判定）
    # target_tab['portofloading']      = exp_df['aaaaa']                      # 启运港（无港口信息）
    # target_tab['portofdestination']  = exp_df['aaaaa']                      # 目的港（无港口信息）
    target_tab['loadingcountrycode'] = ['GBR'] * exp_df.shape[0]           # 启运国国际编码
    target_tab['loadingcountry']     = ['UNITED KINGDOM'] * exp_df.shape[0] # 启运国英文名称
    # target_tab['transportterm']      = exp_df['aaaaa']                      # 运输方式（无运输及成交方式）
    # target_tab['tradeterm']          = exp_df['aaaaa']                      # 成交方式（无运输及成交方式）
    # target_tab['paymentterm']        = exp_df['aaaaa']                      # 付款方式
    # target_tab['carrier']            = exp_df['aaaaa']                      # 承运人名称
    # target_tab['containerno']        = exp_df['aaaaa']                      # 集装箱箱号
    # target_tab['vesselname']         = exp_df['aaaaa']                      # 船名
    # target_tab['brand']              = exp_df['aaaaa']                      # 品牌
    target_tab['version']            = exp_df['version']                      # 版本
    target_tab['country']            = exp_df['src_country']                      # 国家
    # target_tab['IMPORTER_ID']        = exp_df['aaaaa']                      # 渠道采购商编码
    # target_tab['SUPPLIER_ID']        = exp_df['aaaaa']                      # 渠道供应商编码

    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签

    target_tab['cif_currency'] = 'USD'                         # cif货币类型
    target_tab['fob_currency'] = 'USD'                         # fob货币类型

    end = time.time()
    logger.info(f'Export data mapping and cleaning takes {round((end-start)/60,2)} minutes')
    return target_tab.loc[:,config.target_cols]


# 35
def VNM_get_target_import(imp_path, src_cols):
    """
    越南 进口
    35	亚洲	VIETNAM	越南	VNM
    """
    start = time.time()
    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    imp_df = pd.read_csv(imp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {imp_df.columns.values}')
    
    target_tab = pd.DataFrame(columns=config.target_cols)
    
    # 基础字段
    target_tab['channelno'] = ['zdzj'] * imp_df.shape[0]  # 渠道编号
    target_tab['dataid']             = imp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = imp_df['iesign']                    # 进出口标志
    target_tab['writeoffflag'] = ['o'] * imp_df.shape[0]  # 核销标志
    target_tab['datatype'] = ['D'] * imp_df.shape[0]  # 数据类型
    
    # ----------------------------------------------------
    # 1. 基本信息
    target_tab['outputdate'] = pd.to_datetime(imp_df['DECLARATION_DATE'], format='mixed').dt.strftime('%Y-%m-%d').values   # 申报日期
    target_tab['origincountrycode'] = imp_df['ORIGIN_COUNTRY_CODE']  # 原产国代码
    target_tab['origincountry'] = imp_df['ORIGIN_COUNTRY_NAME']  # 原产国名称
    
    # 2. 进口商信息
    target_tab['importername'] = imp_df['IMPORTER_NAME_EN']  # 进口商名称(英语/越南语)
#     target_tab['importername'] = [x[0] if not x[0] else x[1] for x in imp_df.loc[:, ['IMPORTER_NAME_EN', 'IMPORTER_NAME_VN']].values]  # 进口商名称(英语/越南语)
    target_tab['countrycodeofdelivery'] = ['VNM'] * imp_df.shape[0] # 目的国国际编码
    target_tab['countryofdelivery'] = ['VIETNAM'] * imp_df.shape[0] # 目的国英文名称
    
    # 合并进口商地址(1-9 + VN)
#     address_cols = [f'IMPORTER_ADDRESS_{i}' for i in range(1, 10)] + ['IMPORTER_ADDRESS_VN']
#     target_tab['importeraddress'] = imp_df[address_cols].apply(
#         lambda x: ', '.join(x.dropna().astype(str)),
#         axis=1
#     )  # 进口商地址(合并多个字段)
    
    target_tab['importercontact'] = imp_df['IMPORTER_TEL']  # 进口商电话
    target_tab['suppliername'] = imp_df['EXPORTER_NAME']  # 出口商名称
    
    # 3. 出口商地址(1-9 + ZIP)
#     supplier_address_cols = [f'EXPORTER_ADDRESS_{i}' for i in range(1, 10)] + ['EXPORTER_ZIP']
#     target_tab['supplieraddress'] = imp_df[supplier_address_cols].apply(
#         lambda x: ', '.join(x.dropna().astype(str)),
#         axis=1
#     )  # 出口商地址(合并多个字段)
    
    # 4. 产品信息
    target_tab['hscode'] = imp_df['HS_CODE']  # HS编码
    # target_tab['commoditydescription'] = imp_df['PRODUCT_DESC_EN'].fillna(imp_df['PRODUCT_DESC_VN'])  # 产品描述(英语/越南语)
    target_tab['commoditydescription'] = [str(x[0]).replace("\"", " ") if not x[0] else str(x[1]).replace("\"", " ") for x in imp_df.loc[:, ['PRODUCT_DESC_EN', 'PRODUCT_DESC_VN']].values]  # 进口商名称(英语/越南语)
    
    # 5. 价值信息
    # target_tab['totalcifvalue'] = imp_df['TOTAL_VALUE_USD'].fillna(imp_df['TOTAL_VALUE_IN_FC'])  # 总价值(美元/外币)
    target_tab['totalcifvalue'] = imp_df['TOTAL_VALUE_USD']  # 总价值(美元/外币)
    target_tab['quantity'] = imp_df['QUANTITY']  # 数量
    
    # 6. 单位信息
    target_tab['quantityunit'] = imp_df['UNIT_NAME']  # 单位名称/代码
    
    # 7. 运输条款
    # target_tab['transportterm'] = imp_df['TRANS_TYPE_NAME'].fillna(imp_df['TRANS_TYPE_CODE'])  # 运输类型名称/代码
    target_tab['transportterm'] = imp_df['TRANS_TYPE_CODE']  # 运输类型代码
    target_tab['tradeterm'] = imp_df['INCOTERMS']  # 国际贸易术语
    target_tab['paymentterm'] = imp_df['PAYMENT_METHOD']  # 付款方式
    
    # 8. 国家信息
    target_tab['country'] = imp_df['src_country']    # 国家
    target_tab['version'] = imp_df['version'] # 版本
    target_tab['IMPORTER_ID'] = imp_df['IMPORTER_ID']  # 进口商ID

    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签

    target_tab['cif_currency'] = 'USD'                         # cif货币类型
    target_tab['fob_currency'] = 'USD'                         # fob货币类型
    
    end = time.time()
    logger.info(f'Import data mapping and cleaning takes {round((end - start) / 60, 2)} minutes')
    return target_tab.loc[:,config.target_cols]

def VNM_get_target_export(exp_path, src_cols):
    """
    越南 出口
    35	亚洲	VIETNAM	越南	VNM
    """
    start = time.time()
    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    exp_df = pd.read_csv(exp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {exp_df.columns.values}')

    target_tab = pd.DataFrame(columns=config.target_cols)
    
    # 基础字段
    target_tab['channelno'] = ['zdzj'] * exp_df.shape[0]  # 渠道编号
    target_tab['dataid']             = exp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = exp_df['iesign']                    # 进出口标志
    target_tab['writeoffflag'] = ['o'] * exp_df.shape[0]  # 核销标志
    target_tab['datatype'] = ['D'] * exp_df.shape[0]  # 数据类型
    
    # ----------------------------------------------------
    # 1. 基本信息
    target_tab['outputdate'] = pd.to_datetime(exp_df['DECLARATION_DATE'], format='mixed').dt.strftime('%Y-%m-%d').values  # 申报日期
    target_tab['origincountrycode'] = ['VNM']*exp_df.shape[0] # 原产国国际编码
    target_tab['origincountry'] = ['VIETNAM']*exp_df.shape[0] # 原产国英文名称
    target_tab['countrycodeofdelivery'] = exp_df['IMPORTER_COUNTRY_CODE']  # 进口商国家代码
    target_tab['countryofdelivery'] = exp_df['IMPORT_COUNTRY']  # 进口国家
    target_tab['importername'] = exp_df['IMPORTER_NAME']  # 进口商名称
    
    # 2. 进口商地址(1-9)
#     address_cols = [f'IMPORTER_ADDRESS_{i}' for i in range(1, 10)]
#     target_tab['importeraddress'] = exp_df[address_cols].apply(
#         lambda x: ', '.join(x.dropna().astype(str)),
#         axis=1
#     )  # 进口商地址(合并多个字段)
    
    target_tab['importercontact'] = exp_df['IMPORTER_TEL']  # 进口商电话
    target_tab['suppliername'] = exp_df['EXPORTER_NAME_EN'] # 出口商名称(英语)
    # target_tab['suppliername'] = exp_df['EXPORTER_NAME_EN'].fillna(exp_df['EXPORTER_NAME_VN'])  # 出口商名称(英语/越南语)
    #target_tab['suppliername'] = [x[0] if not x[0] else x[1] for x in imp_df.loc[:, ['EXPORTER_NAME_EN', 'EXPORTER_NAME_VN']].values]  # 出口商名称(英语/越南语)
    
    # 3. 出口商地址(VN + 1-9)
#     supplier_address_cols = [f'EXPORTER_ADDRESS_{i}' for i in range(1, 10)] + ['EXPORTER_ADDRESS_VN']
#     target_tab['supplieraddress'] = exp_df[supplier_address_cols].apply(
#         lambda x: ', '.join(x.dropna().astype(str)),
#         axis=1
#     )  # 出口商地址(合并多个字段)
    
#     target_tab['suppliercontact'] = exp_df['EXPORTER_TEL']  # 出口商电话
    target_tab['hscode'] = exp_df['HS_CODE']  # HS编码
    target_tab['commoditydescription'] = exp_df['PRODUCT_DESC_EN']  # 产品描述(英语/越南语)
#     target_tab['commoditydescription'] = [str(x[0]).replace("\"", " ") if not x[0] else str(x[1]).replace("\"", " ") for x in imp_df.loc[:, ['PRODUCT_DESC_EN', 'PRODUCT_DESC_VN']].values]  # 产品描述(英语/越南语)
    
    # 4. 价值信息
    # target_tab['totalcifvalue'] = exp_df['TOTAL_VALUE_USD'].fillna(exp_df['TOTAL_VALUE_IN_FC'])  # 总价值(美元/外币)
    target_tab['totalcifvalue'] = exp_df['TOTAL_VALUE_USD']  # 总价值(美元/外币)
    target_tab['quantity'] = exp_df['QUANTITY']  # 数量
    # target_tab['quantityunit'] = exp_df['UNIT_NAME'].fillna(exp_df['UNIT_CODE'])  # 单位名称/代码
    target_tab['quantityunit'] = exp_df['UNIT_CODE']  # 单位名称/代码
    
    # 5. 装运信息
    target_tab['loadingcountrycode'] = exp_df['LOADING_COUNTRY_CODE']  # 装运国代码
    target_tab['loadingcountry'] = exp_df['LOADING_COUNTRY_NAME']  # 装运国名称
    
    # 6. 运输条款
    # target_tab['transportterm'] = exp_df['TRANS_TYPE_NAME'].fillna(exp_df['TRANS_TYPE_CODE'])  # 运输类型名称/代码
    target_tab['transportterm'] = exp_df['TRANS_TYPE_CODE']  # 运输类型名称/代码
    target_tab['tradeterm'] = exp_df['INCOTERMS']  # 国际贸易术语
    target_tab['paymentterm'] = exp_df['PAYMENT_METHOD']  # 付款方式
    
    # 7. 国家信息
    target_tab['country'] = exp_df['src_country']    # 国家
    target_tab['version'] = exp_df['version'] # 版本
    
    # 8. ID字段
    target_tab['SUPPLIER_ID'] = exp_df['EXPORTER_ID']  # 出口商ID

    target_tab['importer_forwarderagent'] = ['0' if x else '' for x in target_tab['importername'].values] # 采购商货代公司标签
    target_tab['supplier_forwarderagent'] = ['0' if x else '' for x in target_tab['suppliername'].values] # 供应商货代公司标签
    target_tab['cif_currency'] = 'USD'                         # cif货币类型
    target_tab['fob_currency'] = 'USD'                         # fob货币类型
    
    end = time.time()
    logger.info(f'Export data mapping and cleaning takes {round((end - start) / 60, 2)} minutes')
    return target_tab.loc[:,config.target_cols]

# 36
def CHL_get_target_import(imp_path, src_cols):
    """
    智利 进口
    36	拉丁美洲	CHILE	智利	CHL
    """
    start=time.time()
    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    imp_df = pd.read_csv(imp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {imp_df.columns.values}')

    target_tab = pd.DataFrame(columns=config.target_cols)

    target_tab['channelno'] = ['zdzj']*imp_df.shape[0] # 渠道缩写
    target_tab['dataid']             = imp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = imp_df['iesign']                    # 进出口标志
    target_tab['writeoffflag'] = ['o']*imp_df.shape[0] # 冲销标志
    target_tab['outputdate'] = [f'{int(x[0]):04d}-{int(x[1]):02d}-{int(x[2]):02d}' for x in imp_df.loc[:,['YEAR', 'MONTH', 'DAY']].values] # 日期
    # 需要转写为标准英文国名
    target_tab['origincountrycode'] = imp_df['ORIGIN_COUNTRY'] # 原产国国际编码
    target_tab['origincountry'] = imp_df['ORIGIN_COUNTRY'] # 原产国英文名称
    target_tab['countrycodeofdelivery'] = ['CHL'] * imp_df.shape[0] # 目的国国际编码
    target_tab['countryofdelivery'] = ['CHILE'] * imp_df.shape[0] # 目的国英文名称

    target_tab['importername'] = imp_df['IMPORTER'] # 采购商名称
    # target_tab['importeraddress'] = imp_df['aaaaa'] # 采购商地址
    # target_tab['importercontact'] = imp_df['aaaaa'] # 采购商联系方式
    # target_tab['suppliername'] = imp_df['aaaaa'] # 供应商名称
    # target_tab['supplieraddress'] = imp_df['aaaaa'] # 供应商地址
    # target_tab['suppliercontact'] = imp_df['aaaaa'] # 供应商联系方式
    target_tab['hscode'] = imp_df['HS_CODE'] # hs编码
    target_tab['hscodedescription'] = imp_df['HS_CODE_DESC'] # hs编码描述
    target_tab['commoditydescription'] = [str(x).replace("\"", " ") if x is not None else x for x in imp_df['PRODUCT'].values] # 产品描述
    target_tab['totalcifvalue'] = imp_df['CIF'] # cif总价
    target_tab['totalfobvalue'] = imp_df['FOB'] # fob总价
    target_tab['grossweight'] = imp_df['G_WEIGHT'] # 毛重
    # target_tab['netweight'] = imp_df['aaaaa'] # 重量
    target_tab['quantity'] = imp_df['QUANTITY'] # 数量
    target_tab['quantityunit'] = imp_df['UNIT_OF_QUANTITY'] # 数量单位
    # target_tab['teu'] = imp_df['aaaaa'] # TEU
    # 需要判断根据imp_df['IMPORTER']判断是否为0/1
    target_tab['importer_forwarderagent'] = [0]*imp_df.shape[0] # 采购商货代公司标签
    # target_tab['supplier_forwarderagent'] = imp_df['aaaaa'] # 供应商货代公司标签
    # 待判定
    target_tab['abnormaldata'] = [0]*imp_df.shape[0] # 是否命中异常数据规则
    target_tab['portofloading'] = imp_df['ORIGIN_PORT'] # 启运港
    target_tab['portofdestination'] = imp_df['DEST_PORT'] # 目的港
    # 国家需转换为标准英文国名
    target_tab['loadingcountrycode'] = imp_df['ORIGIN_COUNTRY'] # 启运国国际编码
    target_tab['loadingcountry'] = imp_df['ORIGIN_COUNTRY'] # 启运国英文名称

    # 需映射成统一枚举值
    target_tab['transportterm'] = imp_df['TRANS_TYPE'] # 运输方式

    # 需映射成统一枚举值
    target_tab['tradeterm'] = imp_df['INCOTERMS'] # 成交方式
    target_tab['paymentterm'] = imp_df['PAYMENT'] # 付款方式
    target_tab['carrier'] = imp_df['TRANS_CORP'] # 承运人名称
    # target_tab['containerno'] = imp_df['aaaaa'] # 集装箱箱号
    # target_tab['vesselname'] = imp_df['aaaaa'] # 船名
    target_tab['brand'] = imp_df['BRAND'] # 品牌
    target_tab['version'] = imp_df['version'] # 版本
    target_tab['country'] = imp_df['src_country'] # 国家
    target_tab['IMPORTER_ID'] = imp_df['IMPORTER_ID'] # 渠道采购商编码
    # target_tab['SUPPLIER ID'] = imp_df['aaaaa'] # 渠道供应商编码
    # target_tab['writeoffdataid'] = imp_df['aaaaa'] # 冲销记录主键
    target_tab['datatype'] = ['D'] * imp_df.shape[0] # 提单关单标志
    target_tab['cif_currency'] = 'USD'                         # cif货币类型
    target_tab['fob_currency'] = 'USD'                         # fob货币类型
    end=time.time()
    logger.info(f'Import data mapping and cleaning takes {round((end-start)/60,2)} minutes')

    return target_tab.loc[:,config.target_cols]

def CHL_get_target_export(exp_path, src_cols):
    """
    智利 出口
    36	拉丁美洲	CHILE	智利	CHL
    """
    start=time.time()
    # 数据读取
    src_col_type = get_col_str_type(src_cols)
    exp_df = pd.read_csv(exp_path
                         ,header=0
                         , sep=','
                         , quotechar='"'
                         , lineterminator='\n'
                         , on_bad_lines='skip'
                         , encoding='utf-8'
                         , dtype=src_col_type)
    logger.info(f'imp_df columns: {exp_df.columns.values}')

    target_tab = pd.DataFrame(columns=config.target_cols)

    target_tab['channelno'] = ['zdzj']*exp_df.shape[0] # 渠道缩写
    target_tab['dataid']             = exp_df['dataid']                    # 渠道记录主键
    target_tab['iesign']             = exp_df['iesign']                    # 进出口标志
    target_tab['writeoffflag'] = ['o']*exp_df.shape[0] # 冲销标志
    target_tab['outputdate'] = [f'{int(x[0]):04d}-{int(x[1]):02d}-{int(x[2]):02d}' for x in exp_df.loc[:,['YEAR', 'MONTH', 'DAY']].values] # 日期
    # 原产来源国需要再确认
    target_tab['origincountrycode'] = ['CHL']*exp_df.shape[0] # 原产国国际编码
    target_tab['origincountry'] = ['CHILE']*exp_df.shape[0] # 原产国英文名称
    # 需要转写为标准英文国名
    target_tab['countrycodeofdelivery'] = exp_df['DEST_COUNTRY'] # 目的国国际编码
    target_tab['countryofdelivery'] = exp_df['DEST_COUNTRY'] # 目的国英文名称

    # target_tab['importername'] = exp_df['aaaaa'] # 采购商名称
    # target_tab['importeraddress'] = exp_df['aaaaa'] # 采购商地址
    # target_tab['importercontact'] = exp_df['aaaaa'] # 采购商联系方式
    target_tab['suppliername'] = exp_df['EXPORTER'] # 供应商名称
    # target_tab['supplieraddress'] = exp_df['aaaaa'] # 供应商地址
    # target_tab['suppliercontact'] = exp_df['aaaaa'] # 供应商联系方式
    target_tab['hscode'] = exp_df['HS_CODE'] # hs编码
    target_tab['hscodedescription'] = exp_df['HS_CODE_DESC'] # hs编码描述
    target_tab['commoditydescription'] = [str(x).replace("\"", " ") if x is not None else x for x in exp_df['PRODUCT'].values] # 产品描述
    target_tab['totalcifvalue'] = exp_df['CIF'] # cif总价
    target_tab['totalfobvalue'] = exp_df['FOB'] # fob总价
    target_tab['grossweight'] = exp_df['G_WEIGHT'] # 毛重
    # target_tab['netweight'] = exp_df['aaaaa'] # 重量
    target_tab['quantity'] = exp_df['QUANTITY'] # 数量
    target_tab['quantityunit'] = exp_df['UNIT_OF_QUANTITY'] # 数量单位
    # target_tab['teu'] = exp_df['aaaaa'] # TEU
    # target_tab['importer_forwarderagent'] = exp_df['aaaaa'] # 采购商货代公司标签
    # 需要判断根据imp_df['EXPORTER']判断是否为0/1
    target_tab['supplier_forwarderagent'] = [0]*exp_df.shape[0] # 供应商货代公司标签
    # 待判定
    target_tab['abnormaldata'] = [0]*exp_df.shape[0] # 是否命中异常数据规则

    target_tab['portofloading'] = exp_df['ORIGIN_PORT'] # 启运港
    target_tab['portofdestination'] = exp_df['DEST_PORT'] # 目的港
    # 国家需转换为标准英文国名
    target_tab['loadingcountrycode'] = ['CHL']*exp_df.shape[0] # 启运国国际编码
    target_tab['loadingcountry'] = ['CHILE']*exp_df.shape[0] # 启运国英文名称

    # 需映射成统一枚举值
    target_tab['transportterm'] = exp_df['TRANS_TYPE'] # 运输方式

    # 需映射成统一枚举值
    target_tab['tradeterm'] = exp_df['INCOTERMS'] # 成交方式
    target_tab['paymentterm'] = exp_df['PAYMENT'] # 付款方式
    target_tab['carrier'] = exp_df['TRANS_CORP'] # 承运人名称
    # target_tab['containerno'] = exp_df['aaaaa'] # 集装箱箱号
    target_tab['vesselname'] = exp_df['SHIP_NAME'] # 船名
    target_tab['brand'] = exp_df['BRAND'] # 品牌
    target_tab['version'] = exp_df['version'] # 版本
    target_tab['country'] = exp_df['src_country'] # 国家
    # target_tab['IMPORTER ID'] = exp_df['aaaaa'] # 渠道采购商编码
    target_tab['SUPPLIER_ID'] = exp_df['EXPORTER_ID'] # 渠道供应商编码
    # target_tab['writeoffdataid'] = exp_df['aaaaa'] # 冲销记录主键
    target_tab['datatype'] = ['D'] * exp_df.shape[0] # 提单关单标志
    target_tab['cif_currency'] = 'USD'                         # cif货币类型
    target_tab['fob_currency'] = 'USD'                         # fob货币类型

    end=time.time()
    logger.info(f'Export data mapping and cleaning takes {round((end-start)/60,2)} minutes')
    return target_tab.loc[:,config.target_cols]

def get_function_map(country_code_dict):
    """
    输入: country_code_dict, Key为['洲别', '英文国名', '中文国名', '国别编码']
    """
    country_list = ['阿根廷', '埃塞俄比亚', '巴基斯坦', '巴拉圭', '巴拿马', '博兹瓦纳', '俄罗斯陆运', '厄瓜多尔'
                    , '菲律宾', '哥伦比亚', '哥斯达黎加', '哈萨克斯坦', '加纳', '喀麦隆', '科特迪瓦', '肯尼亚'
                    , '莱索托', '马拉维', '美国', '孟加拉', '秘鲁', '秘鲁-海运', '秘鲁-空运', '墨西哥'
                    , '纳米比亚', '尼日利亚', '斯里兰卡', '坦桑尼亚', '乌干达', '乌克兰', '乌拉圭', '乌兹别克斯坦'
                    , '印度', '英国', '越南', '智利']
    function_map = [x for x in country_code_dict if x.get('中文国名') in country_list]
    for x in function_map:
        if x.get('中文国名')=='阿根廷':
            x.update({'import_fuc':ARG_get_target_import, 'export_fuc':ARG_get_target_export})
        if x.get('中文国名')=='埃塞俄比亚':
            x.update({'import_fuc':ETH_get_target_import, 'export_fuc':ETH_get_target_export})
        if x.get('中文国名')=='巴基斯坦':
            x.update({'import_fuc':PAK_get_target_import, 'export_fuc':PAK_get_target_export})
        if x.get('中文国名')=='巴拉圭':
            x.update({'import_fuc':PRY_get_target_import, 'export_fuc':PRY_get_target_export})
        if x.get('中文国名')=='巴拿马':
            x.update({'import_fuc':PAN_get_target_import, 'export_fuc':PAN_get_target_export})
        if x.get('中文国名')=='博兹瓦纳':
            x.update({'import_fuc':BWA_get_target_import, 'export_fuc':BWA_get_target_export})
        if x.get('中文国名')=='俄罗斯陆运':
            x.update({'import_fuc':RUS_get_target_tab})
        if x.get('中文国名')=='厄瓜多尔':
            x.update({'import_fuc':ECU_get_target_import, 'export_fuc':ECU_get_target_export})
        if x.get('中文国名')=='菲律宾':
            x.update({'import_fuc':PHL_get_target_import, 'export_fuc':PHL_get_target_export})
        if x.get('中文国名')=='哥伦比亚':
            x.update({'import_fuc':COL_get_target_import, 'export_fuc':COL_get_target_export})
        if x.get('中文国名')=='哥斯达黎加':
            x.update({'import_fuc':CRI_get_target_import, 'export_fuc':CRI_get_target_export})
        if x.get('中文国名')=='哈萨克斯坦':
            x.update({'import_fuc':KAZ_get_target_import, 'export_fuc':KAZ_get_target_export})
        if x.get('中文国名')=='加纳':
            x.update({'import_fuc':GHA_get_target_import, 'export_fuc':GHA_get_target_export})
        if x.get('中文国名')=='喀麦隆':
            x.update({'import_fuc':CMR_get_target_import})
        if x.get('中文国名')=='科特迪瓦':
            x.update({'import_fuc':CIV_get_target_import, 'export_fuc':CIV_get_target_export})
        if x.get('中文国名')=='肯尼亚':
            x.update({'import_fuc':KEN_get_target_import})
        if x.get('中文国名')=='莱索托':
            x.update({'import_fuc':LSO_get_target_import, 'export_fuc':LSO_get_target_export})
        if x.get('中文国名')=='马拉维':
            x.update({'import_fuc':MWI_get_target_import, 'export_fuc':MWI_get_target_export})
        if x.get('中文国名')=='美国':
            x.update({'import_fuc':USA_get_target_import, 'export_fuc':USA_get_target_export})
        if x.get('中文国名')=='孟加拉':
            x.update({'import_fuc':BGD_get_target_import})
        if x.get('中文国名')=='秘鲁':
            x.update({'import_fuc':PER_get_target_import, 'export_fuc':PER_get_target_export})
        if x.get('中文国名')=='秘鲁-海运':
            x.update({'import_fuc':PER_SEA_get_target_import, 'export_fuc':PER_SEA_get_target_export})
        if x.get('中文国名')=='秘鲁-空运':
            x.update({'import_fuc':PER_AIR_get_target_import, 'export_fuc':PER_AIR_get_target_export})
        if x.get('中文国名')=='墨西哥':
            x.update({'import_fuc':MEX_get_target_import, 'export_fuc':MEX_get_target_export})
        if x.get('中文国名')=='纳米比亚':
            x.update({'import_fuc':NAM_get_target_import})
        if x.get('中文国名')=='尼日利亚':
            x.update({'import_fuc':NGA_get_target_import, 'export_fuc':NGA_get_target_export})
        if x.get('中文国名')=='斯里兰卡':
            x.update({'import_fuc':LKA_get_target_import, 'export_fuc':LKA_get_target_export})
        if x.get('中文国名')=='坦桑尼亚':
            x.update({'import_fuc':TZA_get_target_import, 'export_fuc':TZA_get_target_export})
        if x.get('中文国名')=='乌干达':
            x.update({'import_fuc':UGA_get_target_import, 'export_fuc':UGA_get_target_export})
        if x.get('中文国名')=='乌克兰':
            x.update({'import_fuc':UKR_get_target_import, 'export_fuc':UKR_get_target_export_Access, 'export_fuc2':UKR_get_target_export_Excel})
        if x.get('中文国名')=='乌拉圭':
            x.update({'import_fuc':URY_get_target_import, 'export_fuc':URY_get_target_export})
        if x.get('中文国名')=='乌兹别克斯坦':
            x.update({'import_fuc':UZB_get_target_import, 'export_fuc':UZB_get_target_export})
        if x.get('中文国名')=='印度':
            x.update({'import_fuc':IND_get_target_import, 'export_fuc':IND_get_target_export})
        if x.get('中文国名')=='英国':
            x.update({'import_fuc':GBR_get_target_import, 'export_fuc':GBR_get_target_export})
        if x.get('中文国名')=='越南':
            x.update({'import_fuc':VNM_get_target_import, 'export_fuc':VNM_get_target_export})
        if x.get('中文国名')=='智利':
            x.update({'import_fuc':CHL_get_target_import, 'export_fuc':CHL_get_target_export})
    return function_map

## 36个国家。。。

